■ ハーモニー グラフィックス 1
                                                    

■ マイクロチップ デモソフト”Primitive”  at PIC32MZ + S1D13517ボード + WQVGA 

   
  <試作品仕様>
   ・ Harmonyのグラフィックライブラリのサンプルデモソフトとして マイクロチップから提供されている
      ”Primitive"(C:\microchip\harmony\v1_05\apps\gfx\primitive)を
     下記ハードウェアで実行する
      @ PIC: PIC32MZ2048ECH144
      A グラフィック制御ボード(グラフィックコントローラS1D13517): マイクロチップ Graphics PICtail Plus Epson S1D13517 Board (Part Number: AC164127-7)
      B グラフィック液晶(WQVGA、4.3インチ): マイクロチップ Graphics Display Powertip 4.3in. 480x272 Board (Part Number: AC164127-6)
   
   ・ 開発環境  Harmony ver.1.05、  XC32 ver.1.40、  MPLABX 3.05  PIC32MZ2048ECH144 revison 5
  

  <試作品回路図>(→回路図のPDFファイル

 




<試作品外観>下記の写真には上記回路図にはない、また本テーマと関係のない部品が多々写っています





     

          

   <プログラム例>
//以下、main.c
//--------------------------------------------------------------------------------------------------

/*******************************************************************************
  MPLAB Harmony Project Main Source File

  Company:
    Microchip Technology Inc.
  
  File Name:
    main.c

  Summary:
    This file contains the "main" function for an MPLAB Harmony project.

  Description:
    This file contains the "main" function for an MPLAB Harmony project.  The
    "main" function calls the "SYS_Initialize" function to initialize the state 
    machines of all MPLAB Harmony modules in the system and it calls the 
    "SYS_Tasks" function from within a system-wide "super" loop to maintain 
    their correct operation. These two functions are implemented in 
    configuration-specific files (usually "system_init.c" and "system_tasks.c")
    in a configuration-specific folder under the "src/system_config" folder 
    within this project's top-level folder.  An MPLAB Harmony project may have
    more than one configuration, each contained within it's own folder under
    the "system_config" folder.
 *******************************************************************************/

// DOM-IGNORE-BEGIN
/*******************************************************************************
Copyright (c) 2013-2014 released Microchip Technology Inc.  All rights reserved.

//Microchip licenses to you the right to use, modify, copy and distribute
Software only when embedded on a Microchip microcontroller or digital signal
controller that is integrated into your product or third party product
(pursuant to the sublicense terms in the accompanying license agreement).

You should refer to the license agreement accompanying this Software for
additional information regarding your rights and obligations.

SOFTWARE AND DOCUMENTATION ARE PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND,
EITHER EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION, ANY WARRANTY OF
MERCHANTABILITY, TITLE, NON-INFRINGEMENT AND FITNESS FOR A PARTICULAR PURPOSE.
IN NO EVENT SHALL MICROCHIP OR ITS LICENSORS BE LIABLE OR OBLIGATED UNDER
CONTRACT, NEGLIGENCE, STRICT LIABILITY, CONTRIBUTION, BREACH OF WARRANTY, OR
OTHER LEGAL EQUITABLE THEORY ANY DIRECT OR INDIRECT DAMAGES OR EXPENSES
INCLUDING BUT NOT LIMITED TO ANY INCIDENTAL, SPECIAL, INDIRECT, PUNITIVE OR
CONSEQUENTIAL DAMAGES, LOST PROFITS OR LOST DATA, COST OF PROCUREMENT OF
SUBSTITUTE GOODS, TECHNOLOGY, SERVICES, OR ANY CLAIMS BY THIRD PARTIES
(INCLUDING BUT NOT LIMITED TO ANY DEFENSE THEREOF), OR OTHER SIMILAR COSTS.
 *******************************************************************************/
// DOM-IGNORE-END


// *****************************************************************************
// *****************************************************************************
// Section: Included Files
// *****************************************************************************
// *****************************************************************************

#include <stddef.h>                     // Defines NULL
#include <stdbool.h>                    // Defines true
#include <stdlib.h>                     // Defines EXIT_FAILURE
#include "system/common/sys_module.h"   // SYS function prototypes


// *****************************************************************************
// *****************************************************************************
// Section: Main Entry Point
// *****************************************************************************
// *****************************************************************************

int main ( void )
{
    /* Initialize all MPLAB Harmony modules, including application(s). */
    SYS_Initialize ( NULL );

    while ( true )
    {
        /* Maintain state machines of all polled MPLAB Harmony modules. */
        SYS_Tasks ( );

    }

    /* Execution should not come here during normal operation */

    return ( EXIT_FAILURE );
}


/*******************************************************************************
 End of File
*/




//以下、app.c
//------------------------------------------------------------------------------------
/*******************************************************************************
  MPLAB Harmony Application Source File
  
  Company:
    Microchip Technology Inc.
  
  File Name:
    app.c

  Summary:
    This file contains the source code for the MPLAB Harmony application.

  Description:
    This file contains the source code for the MPLAB Harmony application.  It 
    implements the logic of the application's state machine and it may call 
    API routines of other MPLAB Harmony modules in the system, such as drivers,
    system services, and middleware.  However, it does not call any of the
    system interfaces (such as the "Initialize" and "Tasks" functions) of any of
    the modules in the system or make any assumptions about when those functions
    are called.  That is the responsibility of the configuration-specific system
    files.
 *******************************************************************************/

// DOM-IGNORE-BEGIN
/*******************************************************************************
Copyright (c) 2013-2014 released Microchip Technology Inc.  All rights reserved.

Microchip licenses to you the right to use, modify, copy and distribute
Software only when embedded on a Microchip microcontroller or digital signal
controller that is integrated into your product or third party product
(pursuant to the sublicense terms in the accompanying license agreement).

You should refer to the license agreement accompanying this Software for
additional information regarding your rights and obligations.

SOFTWARE AND DOCUMENTATION ARE PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND,
EITHER EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION, ANY WARRANTY OF
MERCHANTABILITY, TITLE, NON-INFRINGEMENT AND FITNESS FOR A PARTICULAR PURPOSE.
IN NO EVENT SHALL MICROCHIP OR ITS LICENSORS BE LIABLE OR OBLIGATED UNDER
CONTRACT, NEGLIGENCE, STRICT LIABILITY, CONTRIBUTION, BREACH OF WARRANTY, OR
OTHER LEGAL EQUITABLE THEORY ANY DIRECT OR INDIRECT DAMAGES OR EXPENSES
INCLUDING BUT NOT LIMITED TO ANY INCIDENTAL, SPECIAL, INDIRECT, PUNITIVE OR
CONSEQUENTIAL DAMAGES, LOST PROFITS OR LOST DATA, COST OF PROCUREMENT OF
SUBSTITUTE GOODS, TECHNOLOGY, SERVICES, OR ANY CLAIMS BY THIRD PARTIES
(INCLUDING BUT NOT LIMITED TO ANY DEFENSE THEREOF), OR OTHER SIMILAR COSTS.
 *******************************************************************************/
// DOM-IGNORE-END


// *****************************************************************************
// *****************************************************************************
// Section: Included Files 
// *****************************************************************************
// *****************************************************************************

#include "app.h"

// *****************************************************************************
// *****************************************************************************
// Section: Global Data Definitions
// *****************************************************************************
// *****************************************************************************

// *****************************************************************************
/* Application Data

  Summary:
    Holds application data

  Description:
    This structure holds the application's data.

  Remarks:
    This structure should be initialized by the APP_Initialize function.
    
    Application strings and buffers are be defined outside this structure.
*/

APP_DATA appData;

// *****************************************************************************
// *****************************************************************************
// Section: MACROS
// *****************************************************************************
// *****************************************************************************
#define MIN(x,y)                ((x > y)? y: x)
#define APP_SCREEN_DELAY_MS         (1000)
// *****************************************************************************
// *****************************************************************************
// Section: Global Variable Definitions
// *****************************************************************************
// *****************************************************************************

// *****************************************************************************
// *****************************************************************************
// Section: Application Local Routines
// *****************************************************************************
void APP_TMR_DelayMS ( unsigned int delayMs );


// *****************************************************************************
// *****************************************************************************
// Section: Application Callback Functions
// *****************************************************************************
// *****************************************************************************

/* TODO:  Add any necessary callback funtions.
*/


// *****************************************************************************
// *****************************************************************************
// Section: Application Local Functions
// *****************************************************************************
// *****************************************************************************

/* TODO:  Add any necessary local functions.
*/


// *****************************************************************************
// *****************************************************************************
// Section: Application Initialization and State Machine Functions
// *****************************************************************************
// *****************************************************************************

/*******************************************************************************
  Function:
    void APP_Initialize ( void )

  Remarks:
    See prototype in app.h.
 */

void APP_Initialize ( void )
{
    /* Place the App state machine in its initial state. */
    appData.state = APP_STATE_INIT;
    
    /* TODO: Initialize your application's state machine and other
     * parameters.
     */
}


/******************************************************************************
  Function:
    void APP_Tasks ( void )

  Remarks:
    See prototype in app.h.
 */

void APP_Tasks ( void )
{
    /* Check the application's current state. */
    switch ( appData.state )
    {
        /* Application's initial state. */
        case APP_STATE_INIT:
        {
            appData.state = APP_HGC_SCREEN1_DRAW;
            break;
        }
        
        case APP_HGC_SCREEN1_DRAW:
        {
            if(hgcObj.screenState != HGC_SCREEN_STATE_DISPLAY_SCREEN_Screen1)
                return;
            
            GFX_HGC_ChangeScreen(Screen2);
            APP_TMR_DelayMS(1000);
            appData.state = APP_HGC_SCREEN2_DRAW;
            break;
        }    

        case APP_HGC_SCREEN2_DRAW:
        {
            if(hgcObj.screenState != HGC_SCREEN_STATE_DISPLAY_SCREEN_Screen2)
                return;
            
            GFX_HGC_ChangeScreen(Screen3);
            APP_TMR_DelayMS(1000);
            appData.state = APP_HGC_SCREEN3_DRAW;
            break;
        }
        
        case APP_HGC_SCREEN3_DRAW:
        {
            if(hgcObj.screenState != HGC_SCREEN_STATE_DISPLAY_SCREEN_Screen3)
                return;
            
            GFX_HGC_ChangeScreen(Screen1);
            APP_TMR_DelayMS(1000);
            appData.state = APP_HGC_SCREEN1_DRAW;
            break;
        }    

        /* The default state should never be executed. */
        default:
        {
            /* TODO: Handle error in application's state machine. */
            break;
        }
    }
}

void APP_TMR_DelayMS ( unsigned int delayMs )
{
    if(delayMs)
    {
        uint32_t sysClk = SYS_CLK_FREQ;
        uint32_t t0;
        t0 = _CP0_GET_COUNT();
        while (_CP0_GET_COUNT() - t0 < (sysClk/2000)*delayMs);
    }
}
/*******************************************************************************
 End of File
 */





//以下、system_init.c
//---------------------------------------------------------------------------------
/*******************************************************************************
  System Initialization File

  File Name:
    system_init.c

  Summary:
    This file contains source code necessary to initialize the system.

  Description:
    This file contains source code necessary to initialize the system.  It
    implements the "SYS_Initialize" function, defines the configuration bits, 
    and allocates any necessary global system resources, such as the 
    sysObj structure that contains the object handles to all the MPLAB Harmony 
    module objects in the system.
 *******************************************************************************/

// DOM-IGNORE-BEGIN
/*******************************************************************************
Copyright (c) 2013-2015 released Microchip Technology Inc.  All rights reserved.

Microchip licenses to you the right to use, modify, copy and distribute
Software only when embedded on a Microchip microcontroller or digital signal
controller that is integrated into your product or third party product
(pursuant to the sublicense terms in the accompanying license agreement).

You should refer to the license agreement accompanying this Software for
additional information regarding your rights and obligations.

SOFTWARE AND DOCUMENTATION ARE PROVIDED AS IS WITHOUT WARRANTY OF ANY KIND,
EITHER EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION, ANY WARRANTY OF
MERCHANTABILITY, TITLE, NON-INFRINGEMENT AND FITNESS FOR A PARTICULAR PURPOSE.
IN NO EVENT SHALL MICROCHIP OR ITS LICENSORS BE LIABLE OR OBLIGATED UNDER
CONTRACT, NEGLIGENCE, STRICT LIABILITY, CONTRIBUTION, BREACH OF WARRANTY, OR
OTHER LEGAL EQUITABLE THEORY ANY DIRECT OR INDIRECT DAMAGES OR EXPENSES
INCLUDING BUT NOT LIMITED TO ANY INCIDENTAL, SPECIAL, INDIRECT, PUNITIVE OR
CONSEQUENTIAL DAMAGES, LOST PROFITS OR LOST DATA, COST OF PROCUREMENT OF
SUBSTITUTE GOODS, TECHNOLOGY, SERVICES, OR ANY CLAIMS BY THIRD PARTIES
(INCLUDING BUT NOT LIMITED TO ANY DEFENSE THEREOF), OR OTHER SIMILAR COSTS.
 *******************************************************************************/
// DOM-IGNORE-END


// *****************************************************************************
// *****************************************************************************
// Section: Included Files
// *****************************************************************************
// *****************************************************************************

#include "system_config.h"
#include "system_definitions.h"


// ****************************************************************************
// ****************************************************************************
// Section: Configuration Bits
// ****************************************************************************
// ****************************************************************************
// <editor-fold defaultstate="collapsed" desc="Configuration Bits">

/*** DEVCFG0 ***/

#pragma config DEBUG =      OFF
#pragma config JTAGEN =     ON
#pragma config ICESEL =     ICS_PGx1
#pragma config TRCEN =      ON
#pragma config BOOTISA =    MIPS32
#pragma config FECCCON =    OFF_UNLOCKED
#pragma config FSLEEP =     OFF
#pragma config DBGPER =     PG_ALL
#pragma config EJTAGBEN =   NORMAL
#pragma config CP =         OFF

/*** DEVCFG1 ***/

#pragma config FNOSC =      SPLL
#pragma config DMTINTV =    WIN_127_128
#pragma config FSOSCEN =    ON
#pragma config IESO =       ON
#pragma config POSCMOD =    EC
#pragma config OSCIOFNC =   OFF
#pragma config FCKSM =      CSECME
#pragma config WDTPS =      PS1048576
#pragma config WDTSPGM =    STOP
#pragma config FWDTEN =     ON
#pragma config WINDIS =     NORMAL
#pragma config FWDTWINSZ =  WINSZ_25
#pragma config DMTCNT =     DMT31
#pragma config FDMTEN =     ON

/*** DEVCFG2 ***/

#pragma config FPLLIDIV =   DIV_3
#pragma config FPLLRNG =    RANGE_5_10_MHZ
#pragma config FPLLICLK =   PLL_POSC
#pragma config FPLLMULT =   MUL_50
#pragma config FPLLODIV =   DIV_2
#pragma config UPLLFSEL =   FREQ_24MHZ
#pragma config UPLLEN =     ON

/*** DEVCFG3 ***/

#pragma config USERID =     0xffff
#pragma config FMIIEN =     ON
#pragma config FETHIO =     ON
#pragma config PGL1WAY =    ON
#pragma config PMDL1WAY =   ON
#pragma config IOL1WAY =    ON
#pragma config FUSBIDIO =   ON

/*** BF1SEQ0 ***/

#pragma config TSEQ =       0xffff
#pragma config CSEQ =       0xffff
// </editor-fold>


// *****************************************************************************
// *****************************************************************************
// Section: Library/Stack Initialization Data
// *****************************************************************************
// *****************************************************************************



// *****************************************************************************
// *****************************************************************************
// Section: Driver Initialization Data
// *****************************************************************************
// *****************************************************************************

//<editor-fold defaultstate="collapsed" desc="DRV_PMP Initialization Data">
// </editor-fold>
//<editor-fold defaultstate="collapsed" desc="DRV_GFX_S1D13517 Initialization Data">

/*** DRV GFX Initialization Data ***/

DRV_GFX_INIT drvGfxInit =
{
    .orientation             = DISP_ORIENTATION,
    .horizontalResolution    = DISP_HOR_RESOLUTION,
    .verticalResolution      = DISP_VER_RESOLUTION,
    .dataWidth               = DISP_DATA_WIDTH,
    .horizontalPulseWidth    = DISP_HOR_PULSE_WIDTH,
    .horizontalBackPorch     = DISP_HOR_BACK_PORCH,
    .horizontalFrontPorch    = DISP_HOR_FRONT_PORCH,
    .verticalPulseWidth      = DISP_VER_PULSE_WIDTH,
    .verticalBackPorch       = DISP_VER_BACK_PORCH,
    .verticalFrontPorch      = DISP_VER_FRONT_PORCH,
    .logicShift              = DISP_INV_LSHIFT,
    .LCDType                 = 1,
    .colorType               = 0,
    .TCON_Init               = TCON_MODULE,
};


// </editor-fold>

// *****************************************************************************
// *****************************************************************************
// Section: System Data
// *****************************************************************************
// *****************************************************************************

/* Structure to hold the object handles for the modules in the system. */
SYSTEM_OBJECTS sysObj;


// *****************************************************************************
// *****************************************************************************
// Section: Module Initialization Data
// *****************************************************************************
// *****************************************************************************

/*** GFX Initialization Data ***/

 const GFX_INIT gfxInit0 =
{
    .drvInitialize    = NULL,
    .drvOpen          = DRV_GFX_S1D13517_Open,
    .drvInterfaceSet  = DRV_GFX_S1D13517_InterfaceSet,
};

/*******************************************************************************
  Device Control System Service Initialization Data
  
  <editor-fold defaultstate="collapsed" 
  desc="Device Control System Service Initialization Data">
*/

const SYS_DEVCON_INIT sysDevconInit =
{
    .moduleInit = {0},
};

// </editor-fold>


// *****************************************************************************
// *****************************************************************************
// Section: Static Initialization Functions
// *****************************************************************************
// *****************************************************************************


// *****************************************************************************
// *****************************************************************************
// Section: System Initialization
// *****************************************************************************
// *****************************************************************************

/*******************************************************************************
  Function:
    void SYS_Initialize ( SYS_INIT_DATA *data )

  Summary:
    Initializes the board, services, drivers, application and other modules.

  Remarks:
    See prototype in system/common/sys_module.h.
 */

void SYS_Initialize ( void* data )
{
    /* Core Processor Initialization */
    SYS_CLK_Initialize( NULL );
    sysObj.sysDevcon = SYS_DEVCON_Initialize(SYS_DEVCON_INDEX_0, (SYS_MODULE_INIT*)&sysDevconInit);
    SYS_DEVCON_PerformanceConfig(SYS_CLK_SystemFrequencyGet());
    SYS_DEVCON_JTAGDisable();
    SYS_PORTS_Initialize();
    
     
    
    SYS_DEVCON_SystemUnlock();
    //PMP??????????????100MH???25MH?
     PB2DIVbits.PBDIV = 0x03;  //PBCLK2 is SYSCLK divided by 4   //  PMP SPI 1/4 = 100MHz / 4 = 25MHz

    SYS_DEVCON_SystemLock();
    

    /* Board Support Package Initialization */
    //BSP_Initialize();

    /* Initialize Drivers */


    /*Initialize PMP0 */
    DRV_PMP0_Initialize();
    DRV_PMP0_ModeConfig();

    DRV_GFX_S1D13517_Initialize(GFX_INDEX_0, (SYS_MODULE_INIT*)&drvGfxInit);

    /* Initialize System Services */

    /* Initialize Middleware */

    sysObj.gfxObject0 = GFX_Initialize(GFX_INDEX_0, (SYS_MODULE_INIT *)&gfxInit0);

    /* Initialize the Application */
    APP_Initialize();
}


/*******************************************************************************
 End of File
*/





//以下、system_config.h
//----------------------------------------------------------------------------------------------
/*******************************************************************************
  MPLAB Harmony System Configuration Header

  File Name:
    system_config.h

  Summary:
    Build-time configuration header for the system defined by this MPLAB Harmony
    project.

  Description:
    An MPLAB Project may have multiple configurations.  This file defines the
    build-time options for a single configuration.

  Remarks:
    This configuration header must not define any prototypes or data
    definitions (or include any files that do).  It only provides macro
    definitions for build-time configuration options that are not instantiated
    until used by another MPLAB Harmony module or application.
    
    Created with MPLAB Harmony Version 1.05
*******************************************************************************/

// DOM-IGNORE-BEGIN
/*******************************************************************************
Copyright (c) 2013-2015 released Microchip Technology Inc.  All rights reserved.

Microchip licenses to you the right to use, modify, copy and distribute
Software only when embedded on a Microchip microcontroller or digital signal
controller that is integrated into your product or third party product
(pursuant to the sublicense terms in the accompanying license agreement).

You should refer to the license agreement accompanying this Software for
additional information regarding your rights and obligations.

SOFTWARE AND DOCUMENTATION ARE PROVIDED AS IS WITHOUT WARRANTY OF ANY KIND,
EITHER EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION, ANY WARRANTY OF
MERCHANTABILITY, TITLE, NON-INFRINGEMENT AND FITNESS FOR A PARTICULAR PURPOSE.
IN NO EVENT SHALL MICROCHIP OR ITS LICENSORS BE LIABLE OR OBLIGATED UNDER
CONTRACT, NEGLIGENCE, STRICT LIABILITY, CONTRIBUTION, BREACH OF WARRANTY, OR
OTHER LEGAL EQUITABLE THEORY ANY DIRECT OR INDIRECT DAMAGES OR EXPENSES
INCLUDING BUT NOT LIMITED TO ANY INCIDENTAL, SPECIAL, INDIRECT, PUNITIVE OR
CONSEQUENTIAL DAMAGES, LOST PROFITS OR LOST DATA, COST OF PROCUREMENT OF
SUBSTITUTE GOODS, TECHNOLOGY, SERVICES, OR ANY CLAIMS BY THIRD PARTIES
(INCLUDING BUT NOT LIMITED TO ANY DEFENSE THEREOF), OR OTHER SIMILAR COSTS.
*******************************************************************************/
// DOM-IGNORE-END

#ifndef _SYSTEM_CONFIG_H
#define _SYSTEM_CONFIG_H

/* This is a temporary workaround for an issue with the peripheral library "Exists"
   functions that causes superfluous warnings.  It "nulls" out the definition of
   The PLIB function attribute that causes the warning.  Once that issue has been
   resolved, this definition should be removed. */
#define _PLIB_UNSUPPORTED


// *****************************************************************************
// *****************************************************************************
// Section: Included Files
// *****************************************************************************
// *****************************************************************************
/*  This section Includes other configuration headers necessary to completely
    define this configuration.
*/

//#include "bsp_config.h"

// *****************************************************************************
// *****************************************************************************
// Section: System Service Configuration
// *****************************************************************************
// *****************************************************************************

// *****************************************************************************
/* Common System Service Configuration Options
*/
#define SYS_VERSION_STR           "1.05"
#define SYS_VERSION               10500

// *****************************************************************************
/* Clock System Service Configuration Options
*/
#define SYS_CLK_FREQ                        200000000ul
#define SYS_CLK_BUS_PERIPHERAL_1            100000000ul
#define SYS_CLK_BUS_PERIPHERAL_2            100000000ul
#define SYS_CLK_BUS_PERIPHERAL_3            100000000ul
#define SYS_CLK_BUS_PERIPHERAL_4            100000000ul
#define SYS_CLK_BUS_PERIPHERAL_5            100000000ul
#define SYS_CLK_BUS_PERIPHERAL_7            200000000ul
#define SYS_CLK_BUS_PERIPHERAL_8            100000000ul
#define SYS_CLK_CONFIG_PRIMARY_XTAL         24000000ul
#define SYS_CLK_CONFIG_SECONDARY_XTAL       0ul
   
/*** Ports System Service Configuration ***/

#define SYS_PORT_B_ANSEL        0x8fdf
#define SYS_PORT_B_TRIS         0xffdf
#define SYS_PORT_B_LAT          0x0
#define SYS_PORT_B_ODC          0x0
#define SYS_PORT_B_CNPU         0x7000
#define SYS_PORT_B_CNPD         0x0
#define SYS_PORT_B_CNEN         0x0
#define SYS_PORT_C_ANSEL        0xe006
#define SYS_PORT_C_TRIS         0xf01e
#define SYS_PORT_C_LAT          0x0
#define SYS_PORT_C_ODC          0x0
#define SYS_PORT_C_CNPU         0x0
#define SYS_PORT_C_CNPD         0x0
#define SYS_PORT_C_CNEN         0x0

#define SYS_PORT_E_ANSEL        0x300
#define SYS_PORT_E_TRIS         0x3ff
#define SYS_PORT_E_LAT          0x0
#define SYS_PORT_E_ODC          0x0
#define SYS_PORT_E_CNPU         0x0
#define SYS_PORT_E_CNPD         0x0
#define SYS_PORT_E_CNEN         0x0

#define SYS_PORT_G_ANSEL        0x0
#define SYS_PORT_G_TRIS         0xf3c3
#define SYS_PORT_G_LAT          0x0
#define SYS_PORT_G_ODC          0x0
#define SYS_PORT_G_CNPU         0x0
#define SYS_PORT_G_CNPD         0x0
#define SYS_PORT_G_CNEN         0x0

#define SYS_PORT_H_ANSEL        0x70
#define SYS_PORT_H_TRIS         0xfff8
#define SYS_PORT_H_LAT          0x0
#define SYS_PORT_H_ODC          0x0
#define SYS_PORT_H_CNPU         0x0
#define SYS_PORT_H_CNPD         0x0
#define SYS_PORT_H_CNEN         0x0
 
// *****************************************************************************
// *****************************************************************************
// Section: Driver Configuration
// *****************************************************************************
// *****************************************************************************

 #define  GFX_USE_DISPLAY_CONTROLLER_S1D13517

/*** Graphics Display Configuration ***/


#define DISP_ORIENTATION                        0
#define DISP_HOR_RESOLUTION                     480
#define DISP_VER_RESOLUTION                     272
#define DISP_DATA_WIDTH                                 24
#define DISP_HOR_PULSE_WIDTH                    42
#define DISP_HOR_BACK_PORCH                     2
#define DISP_HOR_FRONT_PORCH                    2
#define DISP_VER_PULSE_WIDTH                    10
#define DISP_VER_BACK_PORCH                     2
#define DISP_VER_FRONT_PORCH                    2
#define DISP_INV_LSHIFT                         0
#define GFX_LCD_TYPE                            GFX_LCD_TFT
#define BACKLIGHT_ENABLE_LEVEL                  1
#define BACKLIGHT_DISABLE_LEVEL                 0
#define TCON_MODULE                             NULL
#define TOUCHCAL_ULX                             0x0099
#define TOUCHCAL_ULY                             0x00FF
#define TOUCHCAL_URX                             0x0369
#define TOUCHCAL_URY                             0x00F1
#define TOUCHCAL_LLX                             0x00AC
#define TOUCHCAL_LLY                             0x032A
#define TOUCHCAL_LRX                             0x0368
#define TOUCHCAL_LRY                             0x033C

// DOM-IGNORE-END

#define USE_8BIT_PMP


// *****************************************************************************
// *****************************************************************************
// Section: Middleware & Other Library Configuration
// *****************************************************************************
// *****************************************************************************



/*** GFX Library Configuration ***/

#define GFX_INSTANCES_NUMBER                            1
#define GFX_SELF_PREEMPTION_LEVEL                       0
#define GFX_CONFIG_COLOR_DEPTH                          16

#define GFX_CONFIG_FONT_CHAR_SIZE                       8
#define GFX_CONFIG_FONT_EXTERNAL_DISABLE
#define GFX_CONFIG_FONT_RAM_DISABLE
#define GFX_CONFIG_IMAGE_EXTERNAL_DISABLE
#define GFX_CONFIG_IMAGE_RAM_DISABLE
#define GFX_CONFIG_ALPHABLEND_DISABLE
#define GFX_CONFIG_GRADIENT_DISABLE
#define GFX_CONFIG_PALETTE_DISABLE
#define GFX_CONFIG_FONT_ANTIALIASED_DISABLE
#define GFX_CONFIG_TRANSPARENT_COLOR_DISABLE
#define GFX_CONFIG_PALETTE_EXTERNAL_DISABLE
#define GFX_CONFIG_DOUBLE_BUFFERING_DISABLE
#define GFX_CONFIG_USE_KEYBOARD_DISABLE
#define GFX_CONFIG_USE_TOUCHSCREEN_DISABLE
#define GFX_CONFIG_GOL_DISABLE


// *****************************************************************************
/* BSP Configuration Options
*/
#define BSP_OSC_FREQUENCY 24000000

#endif // _SYSTEM_CONFIG_H
/*******************************************************************************
 End of File
*/




//以下、system_definition.h
//---------------------------------------------------------------------
/*******************************************************************************
  System Definitions

  File Name:
    system_definitions.h

  Summary:
    MPLAB Harmony project system definitions.

  Description:
    This file contains the system-wide prototypes and definitions for an MPLAB
    Harmony project.
 *******************************************************************************/

//DOM-IGNORE-BEGIN
/*******************************************************************************
Copyright (c) 2013-2014 released Microchip Technology Inc.  All rights reserved.

Microchip licenses to you the right to use, modify, copy and distribute
Software only when embedded on a Microchip microcontroller or digital signal
controller that is integrated into your product or third party product
(pursuant to the sublicense terms in the accompanying license agreement).

You should refer to the license agreement accompanying this Software for
additional information regarding your rights and obligations.

SOFTWARE AND DOCUMENTATION ARE PROVIDED AS IS WITHOUT WARRANTY OF ANY KIND,
EITHER EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION, ANY WARRANTY OF
MERCHANTABILITY, TITLE, NON-INFRINGEMENT AND FITNESS FOR A PARTICULAR PURPOSE.
IN NO EVENT SHALL MICROCHIP OR ITS LICENSORS BE LIABLE OR OBLIGATED UNDER
CONTRACT, NEGLIGENCE, STRICT LIABILITY, CONTRIBUTION, BREACH OF WARRANTY, OR
OTHER LEGAL EQUITABLE THEORY ANY DIRECT OR INDIRECT DAMAGES OR EXPENSES
INCLUDING BUT NOT LIMITED TO ANY INCIDENTAL, SPECIAL, INDIRECT, PUNITIVE OR
CONSEQUENTIAL DAMAGES, LOST PROFITS OR LOST DATA, COST OF PROCUREMENT OF
SUBSTITUTE GOODS, TECHNOLOGY, SERVICES, OR ANY CLAIMS BY THIRD PARTIES
(INCLUDING BUT NOT LIMITED TO ANY DEFENSE THEREOF), OR OTHER SIMILAR COSTS.
 *******************************************************************************/
//DOM-IGNORE-END

#ifndef _SYS_DEFINITIONS_H
#define _SYS_DEFINITIONS_H


// *****************************************************************************
// *****************************************************************************
// Section: Included Files
// *****************************************************************************
// *****************************************************************************

#include <stdint.h>
#include <stddef.h>
#include <stdbool.h>
#include "system/common/sys_common.h"
#include "system/common/sys_module.h"
#include "system/clk/sys_clk.h"
#include "system/clk/sys_clk_static.h"
#include "system/devcon/sys_devcon.h"
#include "system/console/sys_console.h"
#include "framework/driver/pmp/drv_pmp_static.h"
#include "system/ports/sys_ports.h"
#include "gfx/gfx.h"
#include "driver/gfx/controller/s1d13517/drv_gfx_s1d13517.h"
#include "system/debug/sys_debug.h"
#include "system/command/sys_command.h"


#include "gfx_hgc_definitions.h"
#include "app.h"


// *****************************************************************************
// *****************************************************************************
// Section: Type Definitions
// *****************************************************************************
// *****************************************************************************

// *****************************************************************************
/* System Objects

  Summary:
    Structure holding the system's object handles

  Description:
    This structure contains the object handles for all objects in the
    MPLAB Harmony project's system configuration.

  Remarks:
    These handles are returned from the "Initialize" functions for each module
    and must be passed into the "Tasks" function for each module.
*/

typedef struct
{
    SYS_MODULE_OBJ  sysDevcon;
    SYS_MODULE_OBJ  gfxObject0;

} SYSTEM_OBJECTS;


// *****************************************************************************
// *****************************************************************************
// Section: extern declarations
// *****************************************************************************
// *****************************************************************************

extern SYSTEM_OBJECTS sysObj;



#if defined (__PIC32MX__)
// Definitions for reset pin
#define DisplayResetConfig()        TRISCCLR = _TRISC_TRISC1_MASK
#define DisplayResetEnable()        LATCCLR = _LATC_LATC1_MASK
#define DisplayResetDisable()       LATCSET = _LATC_LATC1_MASK

// Definitions for RS pin
#define DisplayCmdDataConfig()      TRISCCLR = _TRISC_TRISC2_MASK
#define DisplaySetCommand()         LATCCLR = _LATC_LATC2_MASK
#define DisplaySetData()            LATCSET = _LATC_LATC2_MASK

// Definitions for CS pin
#define DisplayConfig()             TRISDCLR = _TRISD_TRISD10_MASK
#define DisplayEnable()             LATDCLR = _LATD_LATD10_MASK
#define DisplayDisable()            LATDSET = _LATD_LATD10_MASK

// Definitions for backlight control pin
#define DisplayBacklightConfig()    (TRISDbits.TRISD0 = 0)
#define DisplayBacklightOn()        (LATDbits.LATD0 = BACKLIGHT_ENABLE_LEVEL)
#define DisplayBacklightOff()       (LATDbits.LATD0 = BACKLIGHT_DISABLE_LEVEL)
#else


 
//// Definitions for reset pin PIC32MZ    //RG12 <-- RB11
#define DisplayResetConfig()        TRISGCLR = _TRISG_TRISG12_MASK
#define DisplayResetEnable()        LATGCLR = _LATG_LATG12_MASK
#define DisplayResetDisable()       LATGSET = _LATG_LATG12_MASK

//#define DisplayResetConfig()        TRISBCLR = _TRISB_TRISB11_MASK
//#define DisplayResetEnable()        LATBCLR = _LATB_LATB11_MASK
//#define DisplayResetDisable()       LATBSET = _LATB_LATB11_MASK


//// Definitions for RS pin PIC32MZ       //RG13 <-- RB12
#define DisplayCmdDataConfig()      TRISGCLR = _TRISG_TRISG13_MASK
#define DisplaySetCommand()         LATGCLR = _LATG_LATG13_MASK
#define DisplaySetData()            LATGSET = _LATG_LATG13_MASK

//#define DisplayCmdDataConfig()      TRISBCLR = _TRISB_TRISB12_MASK
//#define DisplaySetCommand()         LATBCLR = _LATB_LATB12_MASK
//#define DisplaySetData()            LATBSET = _LATB_LATB12_MASK



//// Definitions for CS pin PIC32MZ     //RG14 <-- RJ5
#define DisplayConfig()             TRISGCLR = _TRISG_TRISG14_MASK
#define DisplayEnable()             LATGCLR = _LATG_LATG14_MASK
#define DisplayDisable()            LATGSET = _LATG_LATG14_MASK

//#define DisplayConfig()             TRISJCLR = _TRISJ_TRISJ5_MASK
//#define DisplayEnable()             LATJCLR = _LATJ_LATJ5_MASK
//#define DisplayDisable()            LATJSET = _LATJ_LATJ5_MASK






// Definitions for backlight control pin PIC32MZ
#define DisplayBacklightConfig()    (TRISJbits.TRISJ6 = 0)
#define DisplayBacklightOn()        (LATJbits.LATJ6 = BACKLIGHT_ENABLE_LEVEL)
#define DisplayBacklightOff()       (LATJbits.LATJ6 = BACKLIGHT_DISABLE_LEVEL)
#endif

// Definitions for FLASH CS pin
#define DisplayFlashConfig()
#define DisplayFlashEnable()
#define DisplayFlashDisable()

// Definitions for POWER ON pin
#define DisplayPowerConfig()
#define DisplayPowerOn()
#define DisplayPowerOff()

// ADC channel constants
// resistive touch X and Y voltage sensing
#define ADC_XPOS                 (0xB << _AD1CHS_CH0SA_POSITION)
#define ADC_YPOS                 (0xA << _AD1CHS_CH0SA_POSITION)


#define ADPCFG_XPOS              AD1PCFGbits.PCFG11
#define ADPCFG_YPOS              AD1PCFGbits.PCFG10
#define RESISTIVETOUCH_ANALOG  0
#define RESISTIVETOUCH_DIGITAL 1

#define ResistiveTouchScreen_XMinus_Drive_High()        LATDbits.LATD9   = 1
#define ResistiveTouchScreen_XMinus_Drive_Low()         LATDbits.LATD9   = 0
#define ResistiveTouchScreen_XMinus_Config_As_Input()   TRISDbits.TRISD9 = 1
#define ResistiveTouchScreen_XMinus_Config_As_Output()  TRISDbits.TRISD9 = 0

#define ResistiveTouchScreen_YMinus_Drive_High()        LATDbits.LATD8    = 1
#define ResistiveTouchScreen_YMinus_Drive_Low()         LATDbits.LATD8    = 0
#define ResistiveTouchScreen_YMinus_Config_As_Input()   TRISDbits.TRISD8  = 1
#define ResistiveTouchScreen_YMinus_Config_As_Output()  TRISDbits.TRISD8  = 0

// X port definitions
#define ResistiveTouchScreen_XPlus_Drive_High()             LATBbits.LATB11   = 1
#define ResistiveTouchScreen_XPlus_Drive_Low()              LATBbits.LATB11   = 0
#define ResistiveTouchScreen_XPlus_Config_As_Input()        TRISBbits.TRISB11 = 1
#define ResistiveTouchScreen_XPlus_Config_As_Output()       TRISBbits.TRISB11 = 0

// Y port definitions
#define ResistiveTouchScreen_YPlus_Drive_High()             LATBbits.LATB10   = 1
#define ResistiveTouchScreen_YPlus_Drive_Low()              LATBbits.LATB10   = 0
#define ResistiveTouchScreen_YPlus_Config_As_Input()        TRISBbits.TRISB10 = 1
#define ResistiveTouchScreen_YPlus_Config_As_Output()       TRISBbits.TRISB10 = 0


// Potentiometer and Temperature sensor
#define ADC_TEMP                 ADC_CH0_POS_SAMPLEA_AN4
#define TOUCH_ADC_INPUT_SEL   AD1CHS

// ADC Sample Start
#define TOUCH_ADC_START   AD1CON1bits.SAMP

// ADC Status
#define TOUCH_ADC_DONE   AD1CON1bits.DONE

#define ADDRESS_RESISTIVE_TOUCH_VERSION (unsigned long)0xFFFFFFFE
#define ADDRESS_RESISTIVE_TOUCH_ULX   (unsigned long)0xFFFFFFFC
#define ADDRESS_RESISTIVE_TOUCH_ULY   (unsigned long)0xFFFFFFFA
#define ADDRESS_RESISTIVE_TOUCH_URX   (unsigned long)0xFFFFFFF8
#define ADDRESS_RESISTIVE_TOUCH_URY   (unsigned long)0xFFFFFFF6

#define ADDRESS_RESISTIVE_TOUCH_LLX   (unsigned long)0xFFFFFFF4
#define ADDRESS_RESISTIVE_TOUCH_LLY   (unsigned long)0xFFFFFFF2
#define ADDRESS_RESISTIVE_TOUCH_LRX   (unsigned long)0xFFFFFFF0
#define ADDRESS_RESISTIVE_TOUCH_LRY   (unsigned long)0xFFFFFFEE

#define SST25_CS_TRIS   TRISDbits.TRISD1
#define SST25_CS_LAT    LATDbits.LATD1

#define SST25_SCK_TRIS  TRISGbits.TRISG6
#define SST25_SDO_TRIS  TRISGbits.TRISG8
#define SST25_SDI_TRIS  TRISGbits.TRISG7

#define USE_GFX_PMP
#define PMP_DATA_SETUP_TIME                (18)
#define PMP_DATA_WAIT_TIME                 (82)  // based on the minimum pulse width requirement of CS signal of SSD1926
#define PMP_DATA_HOLD_TIME                 (0)


#endif /* _SYS_DEFINITIONS_H */
/*******************************************************************************
 End of File
*/




<実行結果>

1. ピクチャー
 

 モード  各液晶画面
 primitive 画面@  
 primitive 画面A  
 primitive 画面B  



2. 動画 ---> YouYube


  


■ マイクロチップ デモソフト”Primitive + Hellow”  at PIC32MZ + SSD1926 ボード + QVGA 

   
  <試作品仕様>
   ・ Harmonyのグラフィックライブラリのサンプルデモソフトとして マイクロチップから提供されている
      ”Primitive"(C:\microchip\harmony\v1_05\apps\gfx\primitive)を
     下記ハードウェアで実行する
      @ PIC: PIC32MZ2048ECH100
      A グラフィック制御ボード(グラフィックコントローラS1D13517): マイクロチップ Graphics LCD Controller PICtail Plus SSD1926 Board (Part Number: AC164127-5)
      B グラフィック液晶(WQVGA、4.3インチ): マイクロチップ Graphics Display Truly 240x320 QVGA 3.2" Board (Part Number: AC164127-4)
   ・ primitive には3画面あるが、1画面を追加して ”Hellow World !!”を表示すること。

   ・ 開発環境  Harmony ver.1.05、  XC32 ver.1.40、  MPLABX 3.05  PIC32MZ2048ECH100 revison 5
  

  <試作品回路図>(→回路図のPDFファイル


 

<試作品外観>下記の写真には上記回路図にはない、また本テーマと関係のない部品が多々写っています



    

          

   <プログラム例>

//以下、 main.c
//----------------------------------------------------------------------------------------
/*******************************************************************************
  MPLAB Harmony Project Main Source File

  Company:
    Microchip Technology Inc.
  
  File Name:
    main.c

  Summary:
    This file contains the "main" function for an MPLAB Harmony project.

  Description:
    This file contains the "main" function for an MPLAB Harmony project.  The
    "main" function calls the "SYS_Initialize" function to initialize the state 
    machines of all MPLAB Harmony modules in the system and it calls the 
    "SYS_Tasks" function from within a system-wide "super" loop to maintain 
    their correct operation. These two functions are implemented in 
    configuration-specific files (usually "system_init.c" and "system_tasks.c")
    in a configuration-specific folder under the "src/system_config" folder 
    within this project's top-level folder.  An MPLAB Harmony project may have
    more than one configuration, each contained within it's own folder under
    the "system_config" folder.
 *******************************************************************************/

// DOM-IGNORE-BEGIN
/*******************************************************************************
Copyright (c) 2013-2014 released Microchip Technology Inc.  All rights reserved.

//Microchip licenses to you the right to use, modify, copy and distribute
Software only when embedded on a Microchip microcontroller or digital signal
controller that is integrated into your product or third party product
(pursuant to the sublicense terms in the accompanying license agreement).

You should refer to the license agreement accompanying this Software for
additional information regarding your rights and obligations.

SOFTWARE AND DOCUMENTATION ARE PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND,
EITHER EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION, ANY WARRANTY OF
MERCHANTABILITY, TITLE, NON-INFRINGEMENT AND FITNESS FOR A PARTICULAR PURPOSE.
IN NO EVENT SHALL MICROCHIP OR ITS LICENSORS BE LIABLE OR OBLIGATED UNDER
CONTRACT, NEGLIGENCE, STRICT LIABILITY, CONTRIBUTION, BREACH OF WARRANTY, OR
OTHER LEGAL EQUITABLE THEORY ANY DIRECT OR INDIRECT DAMAGES OR EXPENSES
INCLUDING BUT NOT LIMITED TO ANY INCIDENTAL, SPECIAL, INDIRECT, PUNITIVE OR
CONSEQUENTIAL DAMAGES, LOST PROFITS OR LOST DATA, COST OF PROCUREMENT OF
SUBSTITUTE GOODS, TECHNOLOGY, SERVICES, OR ANY CLAIMS BY THIRD PARTIES
(INCLUDING BUT NOT LIMITED TO ANY DEFENSE THEREOF), OR OTHER SIMILAR COSTS.
 *******************************************************************************/
// DOM-IGNORE-END


// *****************************************************************************
// *****************************************************************************
// Section: Included Files
// *****************************************************************************
// *****************************************************************************

#include <stddef.h>                     // Defines NULL
#include <stdbool.h>                    // Defines true
#include <stdlib.h>                     // Defines EXIT_FAILURE
#include "system/common/sys_module.h"   // SYS function prototypes


// *****************************************************************************
// *****************************************************************************
// Section: Main Entry Point
// *****************************************************************************
// *****************************************************************************

int main ( void )
{
    /* Initialize all MPLAB Harmony modules, including application(s). */
    SYS_Initialize ( NULL );


    while ( true )
    {
        /* Maintain state machines of all polled MPLAB Harmony modules. */
        SYS_Tasks ( );

    }

    /* Execution should not come here during normal operation */

    return ( EXIT_FAILURE );
}


/*******************************************************************************
 End of File
*/



//以下、app.h
//-----------------------------------------------------------------------
/*******************************************************************************
  MPLAB Harmony Application Header File

  Company:
    Microchip Technology Inc.

  File Name:
    app.h

  Summary:
    This header file provides prototypes and definitions for the application.

  Description:
    This header file provides function prototypes and data type definitions for
    the application.  Some of these are required by the system (such as the
    "APP_Initialize" and "APP_Tasks" prototypes) and some of them are only used
    internally by the application (such as the "APP_STATES" definition).  Both
    are defined here for convenience.
*******************************************************************************/

//DOM-IGNORE-BEGIN
/*******************************************************************************
Copyright (c) 2013-2014 released Microchip Technology Inc.  All rights reserved.

Microchip licenses to you the right to use, modify, copy and distribute
Software only when embedded on a Microchip microcontroller or digital signal
controller that is integrated into your product or third party product
(pursuant to the sublicense terms in the accompanying license agreement).

You should refer to the license agreement accompanying this Software for
additional information regarding your rights and obligations.

SOFTWARE AND DOCUMENTATION ARE PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND,
EITHER EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION, ANY WARRANTY OF
MERCHANTABILITY, TITLE, NON-INFRINGEMENT AND FITNESS FOR A PARTICULAR PURPOSE.
IN NO EVENT SHALL MICROCHIP OR ITS LICENSORS BE LIABLE OR OBLIGATED UNDER
CONTRACT, NEGLIGENCE, STRICT LIABILITY, CONTRIBUTION, BREACH OF WARRANTY, OR
OTHER LEGAL EQUITABLE THEORY ANY DIRECT OR INDIRECT DAMAGES OR EXPENSES
INCLUDING BUT NOT LIMITED TO ANY INCIDENTAL, SPECIAL, INDIRECT, PUNITIVE OR
CONSEQUENTIAL DAMAGES, LOST PROFITS OR LOST DATA, COST OF PROCUREMENT OF
SUBSTITUTE GOODS, TECHNOLOGY, SERVICES, OR ANY CLAIMS BY THIRD PARTIES
(INCLUDING BUT NOT LIMITED TO ANY DEFENSE THEREOF), OR OTHER SIMILAR COSTS.
 *******************************************************************************/
//DOM-IGNORE-END

#ifndef _APP_H
#define _APP_H

// *****************************************************************************
// *****************************************************************************
// Section: Included Files
// *****************************************************************************
// *****************************************************************************

#include <stdint.h>
#include <stdbool.h>
#include <stddef.h>
#include <stdlib.h>
#include "system_config.h"
#include "system_definitions.h"

// *****************************************************************************
// *****************************************************************************
// Section: Type Definitions
// *****************************************************************************
// *****************************************************************************

// *****************************************************************************
/* Application states

  Summary:
    Application states enumeration

  Description:
    This enumeration defines the valid application states.  These states
    determine the behavior of the application at various times.
*/

typedef enum
{
       /* Application pixels put*/
    APP_STATE_INIT=0,

    /* Application primitive draw */
    //APP_PRIMITIVE_DRAW,
            
    APP_HGC_SCREEN1_DRAW,
            
    APP_HGC_SCREEN2_DRAW,
            
    APP_HGC_SCREEN3_DRAW,
            
    APP_HGC_SCREEN4_DRAW,        

    /* Application done */
    APP_STATE_DONE,

} APP_STATES;


// *****************************************************************************
/* Application Data

  Summary:
    Holds application data

  Description:
    This structure holds the application's data.

  Remarks:
    Application strings and buffers are be defined outside this structure.
 */

typedef struct
{
 
    /* Application's current state*/
    APP_STATES state;

    GFX_HANDLE gfxHandle[GFX_INSTANCES_NUMBER];


} APP_DATA;


// *****************************************************************************
// *****************************************************************************
// Section: Application Callback Routines
// *****************************************************************************
// *****************************************************************************
/* These routines are called by drivers when certain events occur.
*/

        
// *****************************************************************************
// *****************************************************************************
// Section: Application Initialization and State Machine Functions
// *****************************************************************************
// *****************************************************************************

/*******************************************************************************
  Function:
    void APP_Initialize ( void )

  Summary:
     MPLAB Harmony application initialization routine.

  Description:
    This function initializes the Harmony application.  It places the 
    application in its initial state and prepares it to run so that its 
    APP_Tasks function can be called.

  Precondition:
    All other system initialization routines should be called before calling
    this routine (in "SYS_Initialize").

  Parameters:
    None.

  Returns:
    None.

  Example:
    <code>
    APP_Initialize();
    </code>

  Remarks:
    This routine must be called from the SYS_Initialize function.
*/

void APP_Initialize ( void );


/*******************************************************************************
  Function:
    void APP_Tasks ( void )

  Summary:
    MPLAB Harmony Demo application tasks function

  Description:
    This routine is the Harmony Demo application's tasks function.  It
    defines the application's state machine and core logic.

  Precondition:
    The system and application initialization ("SYS_Initialize") should be
    called before calling this.

  Parameters:
    None.

  Returns:
    None.

  Example:
    <code>
    APP_Tasks();
    </code>

  Remarks:
    This routine must be called from SYS_Tasks() routine.
 */

void APP_Tasks( void );


#endif /* _APP_H */
/*******************************************************************************
 End of File
 */





//以下、app.c
//-----------------------------------------------------------------------------------------
/*******************************************************************************
  MPLAB Harmony Application Source File
  
  Company:
    Microchip Technology Inc.
  
  File Name:
    app.c

  Summary:
    This file contains the source code for the MPLAB Harmony application.

  Description:
    This file contains the source code for the MPLAB Harmony application.  It 
    implements the logic of the application's state machine and it may call 
    API routines of other MPLAB Harmony modules in the system, such as drivers,
    system services, and middleware.  However, it does not call any of the
    system interfaces (such as the "Initialize" and "Tasks" functions) of any of
    the modules in the system or make any assumptions about when those functions
    are called.  That is the responsibility of the configuration-specific system
    files.
 *******************************************************************************/

// DOM-IGNORE-BEGIN
/*******************************************************************************
Copyright (c) 2013-2014 released Microchip Technology Inc.  All rights reserved.

Microchip licenses to you the right to use, modify, copy and distribute
Software only when embedded on a Microchip microcontroller or digital signal
controller that is integrated into your product or third party product
(pursuant to the sublicense terms in the accompanying license agreement).

You should refer to the license agreement accompanying this Software for
additional information regarding your rights and obligations.

SOFTWARE AND DOCUMENTATION ARE PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND,
EITHER EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION, ANY WARRANTY OF
MERCHANTABILITY, TITLE, NON-INFRINGEMENT AND FITNESS FOR A PARTICULAR PURPOSE.
IN NO EVENT SHALL MICROCHIP OR ITS LICENSORS BE LIABLE OR OBLIGATED UNDER
CONTRACT, NEGLIGENCE, STRICT LIABILITY, CONTRIBUTION, BREACH OF WARRANTY, OR
OTHER LEGAL EQUITABLE THEORY ANY DIRECT OR INDIRECT DAMAGES OR EXPENSES
INCLUDING BUT NOT LIMITED TO ANY INCIDENTAL, SPECIAL, INDIRECT, PUNITIVE OR
CONSEQUENTIAL DAMAGES, LOST PROFITS OR LOST DATA, COST OF PROCUREMENT OF
SUBSTITUTE GOODS, TECHNOLOGY, SERVICES, OR ANY CLAIMS BY THIRD PARTIES
(INCLUDING BUT NOT LIMITED TO ANY DEFENSE THEREOF), OR OTHER SIMILAR COSTS.
 *******************************************************************************/
// DOM-IGNORE-END


// *****************************************************************************
// *****************************************************************************
// Section: Included Files 
// *****************************************************************************
// *****************************************************************************

#include "app.h"

// *****************************************************************************
// *****************************************************************************
// Section: Global Data Definitions
// *****************************************************************************
// *****************************************************************************

// *****************************************************************************
/* Application Data

  Summary:
    Holds application data

  Description:
    This structure holds the application's data.

  Remarks:
    This structure should be initialized by the APP_Initialize function.
    
    Application strings and buffers are be defined outside this structure.
*/

APP_DATA appData;



// *****************************************************************************
// *****************************************************************************
// Section: MACROS
// *****************************************************************************
// *****************************************************************************
#define MIN(x,y)                ((x > y)? y: x)
#define APP_SCREEN_DELAY_MS         (1000)
// *****************************************************************************
// *****************************************************************************
// Section: Global Variable Definitions
// *****************************************************************************
// *****************************************************************************

// *****************************************************************************
// *****************************************************************************
// Section: Application Local Routines
// *****************************************************************************
void APP_TMR_DelayMS ( unsigned int delayMs );


// *****************************************************************************
// *****************************************************************************
// Section: Application Callback Functions
// *****************************************************************************
// *****************************************************************************

/* TODO:  Add any necessary callback funtions.
*/

// *****************************************************************************
// *****************************************************************************
// Section: Application Local Functions
// *****************************************************************************
// *****************************************************************************

/* TODO:  Add any necessary local functions.
*/


// *****************************************************************************
// *****************************************************************************
// Section: Application Initialization and State Machine Functions
// *****************************************************************************
// *****************************************************************************

/*******************************************************************************
  Function:
    void APP_Initialize ( void )

  Remarks:
    See prototype in app.h.
 */

void APP_Initialize ( void )
{
    /* Place the App state machine in its initial state. */
    appData.state = APP_STATE_INIT;
    
    /* TODO: Initialize your application's state machine and other
     * parameters.
     */
}


/******************************************************************************
  Function:
    void APP_Tasks ( void )

  Remarks:
    See prototype in app.h.
 */

void APP_Tasks ( void )
{
    /* Check the application's current state. */
    switch ( appData.state )
    {
        /* Application's initial state. */
        case APP_STATE_INIT:
        {
            appData.state = APP_HGC_SCREEN1_DRAW;
            break;
        }
        
        case APP_HGC_SCREEN1_DRAW:
        {
            if(hgcObj.screenState != HGC_SCREEN_STATE_DISPLAY_SCREEN_screen1)
                return;
            
            GFX_HGC_ChangeScreen(screen2);
            APP_TMR_DelayMS(1000);
            appData.state = APP_HGC_SCREEN2_DRAW;
            break;
        }    

        case APP_HGC_SCREEN2_DRAW:
        {
            if(hgcObj.screenState != HGC_SCREEN_STATE_DISPLAY_SCREEN_screen2)
                return;
            
            GFX_HGC_ChangeScreen(screen3);
            APP_TMR_DelayMS(1000);
            appData.state = APP_HGC_SCREEN3_DRAW;
            break;
        }
        
        case APP_HGC_SCREEN3_DRAW:
        {
            if(hgcObj.screenState != HGC_SCREEN_STATE_DISPLAY_SCREEN_screen3)
                return;
            
            GFX_HGC_ChangeScreen(screen4);
            APP_TMR_DelayMS(1000);
            appData.state = APP_HGC_SCREEN4_DRAW;
            break;
        } 
        
         case APP_HGC_SCREEN4_DRAW:
        {
            if(hgcObj.screenState != HGC_SCREEN_STATE_DISPLAY_SCREEN_screen4)
                return;
            
            GFX_HGC_ChangeScreen(screen1);
            APP_TMR_DelayMS(1000);
            appData.state = APP_HGC_SCREEN1_DRAW;
            break;
        } 
        
        

        /* The default state should never be executed. */
        default:
        {
            /* TODO: Handle error in application's state machine. */
            break;
        }
    }
}

void APP_TMR_DelayMS ( unsigned int delayMs )
{
    if(delayMs)
    {
        uint32_t sysClk = SYS_CLK_FREQ;
        uint32_t t0;
        t0 = _CP0_GET_COUNT();
        while (_CP0_GET_COUNT() - t0 < (sysClk/2000)*delayMs);
    }
}

/*******************************************************************************
 End of File
 */





//以下、system_config.h
//-------------------------------------------------------------------------
/*******************************************************************************
  MPLAB Harmony System Configuration Header

  File Name:
    system_config.h

  Summary:
    Build-time configuration header for the system defined by this MPLAB Harmony
    project.

  Description:
    An MPLAB Project may have multiple configurations.  This file defines the
    build-time options for a single configuration.

  Remarks:
    This configuration header must not define any prototypes or data
    definitions (or include any files that do).  It only provides macro
    definitions for build-time configuration options that are not instantiated
    until used by another MPLAB Harmony module or application.
    
    Created with MPLAB Harmony Version 1.05
*******************************************************************************/

// DOM-IGNORE-BEGIN
/*******************************************************************************
Copyright (c) 2013-2015 released Microchip Technology Inc.  All rights reserved.

Microchip licenses to you the right to use, modify, copy and distribute
Software only when embedded on a Microchip microcontroller or digital signal
controller that is integrated into your product or third party product
(pursuant to the sublicense terms in the accompanying license agreement).

You should refer to the license agreement accompanying this Software for
additional information regarding your rights and obligations.

SOFTWARE AND DOCUMENTATION ARE PROVIDED AS IS WITHOUT WARRANTY OF ANY KIND,
EITHER EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION, ANY WARRANTY OF
MERCHANTABILITY, TITLE, NON-INFRINGEMENT AND FITNESS FOR A PARTICULAR PURPOSE.
IN NO EVENT SHALL MICROCHIP OR ITS LICENSORS BE LIABLE OR OBLIGATED UNDER
CONTRACT, NEGLIGENCE, STRICT LIABILITY, CONTRIBUTION, BREACH OF WARRANTY, OR
OTHER LEGAL EQUITABLE THEORY ANY DIRECT OR INDIRECT DAMAGES OR EXPENSES
INCLUDING BUT NOT LIMITED TO ANY INCIDENTAL, SPECIAL, INDIRECT, PUNITIVE OR
CONSEQUENTIAL DAMAGES, LOST PROFITS OR LOST DATA, COST OF PROCUREMENT OF
SUBSTITUTE GOODS, TECHNOLOGY, SERVICES, OR ANY CLAIMS BY THIRD PARTIES
(INCLUDING BUT NOT LIMITED TO ANY DEFENSE THEREOF), OR OTHER SIMILAR COSTS.
*******************************************************************************/
// DOM-IGNORE-END

#ifndef _SYSTEM_CONFIG_H
#define _SYSTEM_CONFIG_H

/* This is a temporary workaround for an issue with the peripheral library "Exists"
   functions that causes superfluous warnings.  It "nulls" out the definition of
   The PLIB function attribute that causes the warning.  Once that issue has been
   resolved, this definition should be removed. */
#define _PLIB_UNSUPPORTED


// *****************************************************************************
// *****************************************************************************
// Section: Included Files
// *****************************************************************************
// *****************************************************************************
/*  This section Includes other configuration headers necessary to completely
    define this configuration.
*/


// *****************************************************************************
// *****************************************************************************
// Section: System Service Configuration
// *****************************************************************************
// *****************************************************************************

// *****************************************************************************
/* Common System Service Configuration Options
*/
#define SYS_VERSION_STR           "1.05"
#define SYS_VERSION               10500

// *****************************************************************************
/* Clock System Service Configuration Options
*/
#define SYS_CLK_FREQ                        200000000ul
#define SYS_CLK_BUS_PERIPHERAL_1            100000000ul
#define SYS_CLK_BUS_PERIPHERAL_2            100000000ul
#define SYS_CLK_BUS_PERIPHERAL_3            100000000ul
#define SYS_CLK_BUS_PERIPHERAL_4            100000000ul
#define SYS_CLK_BUS_PERIPHERAL_5            100000000ul
#define SYS_CLK_BUS_PERIPHERAL_7            200000000ul
#define SYS_CLK_BUS_PERIPHERAL_8            100000000ul
#define SYS_CLK_CONFIG_PRIMARY_XTAL         24000000ul
#define SYS_CLK_CONFIG_SECONDARY_XTAL       0ul
   
/*** Ports System Service Configuration ***/
#define SYS_PORT_C_ANSEL        0xf006
#define SYS_PORT_C_TRIS         0xf01e
#define SYS_PORT_C_LAT          0x0
#define SYS_PORT_C_ODC          0x0
#define SYS_PORT_C_CNPU         0x0
#define SYS_PORT_C_CNPD         0x0
#define SYS_PORT_C_CNEN         0x0

#define SYS_PORT_E_ANSEL        0x300
#define SYS_PORT_E_TRIS         0x3ff
#define SYS_PORT_E_LAT          0x0
#define SYS_PORT_E_ODC          0x0
#define SYS_PORT_E_CNPU         0x0
#define SYS_PORT_E_CNPD         0x0
#define SYS_PORT_E_CNEN         0x0
 
// *****************************************************************************
// *****************************************************************************
// Section: Driver Configuration
// *****************************************************************************
// *****************************************************************************

 #define  GFX_USE_DISPLAY_CONTROLLER_SSD1926

/*** Graphics Display Configuration ***/


#define DISP_ORIENTATION                        90
#define DISP_HOR_RESOLUTION                     240
#define DISP_VER_RESOLUTION                     320
#define DISP_DATA_WIDTH                                 18
#define DISP_HOR_PULSE_WIDTH                    25
#define DISP_HOR_BACK_PORCH                     5
#define DISP_HOR_FRONT_PORCH                    10
#define DISP_VER_PULSE_WIDTH                    4
#define DISP_VER_BACK_PORCH                     0
#define DISP_VER_FRONT_PORCH                    2
#define DISP_INV_LSHIFT                         1
#define GFX_LCD_TYPE                            GFX_LCD_TFT
#define BACKLIGHT_ENABLE_LEVEL                  0
#define BACKLIGHT_DISABLE_LEVEL                 1
#define USE_TCON_SSD1289
#define TCON_MODULE                             GFX_TCON_SSD1289Init
#define USE_TCON_MODULE                         0
#define GFX_USE_TCON_CUSTOM
#define TOUCHCAL_ULX                             0x00C0
#define TOUCHCAL_ULY                             0x00D4
#define TOUCHCAL_URX                             0x037C
#define TOUCHCAL_URY                             0x00D7
#define TOUCHCAL_LLX                             0x00B9
#define TOUCHCAL_LLY                             0x0350
#define TOUCHCAL_LRX                             0x035A
#define TOUCHCAL_LRY                             0x0333

// DOM-IGNORE-END

#define USE_8BIT_PMP


// *****************************************************************************
// *****************************************************************************
// Section: Middleware & Other Library Configuration
// *****************************************************************************
// *****************************************************************************



/*** GFX Library Configuration ***/

#define GFX_INSTANCES_NUMBER                            1
#define GFX_SELF_PREEMPTION_LEVEL                       0
#define GFX_CONFIG_COLOR_DEPTH                          16

#define GFX_CONFIG_FONT_CHAR_SIZE                       8
#define GFX_CONFIG_FONT_EXTERNAL_DISABLE
#define GFX_CONFIG_FONT_RAM_DISABLE
#define GFX_CONFIG_IMAGE_EXTERNAL_DISABLE
#define GFX_CONFIG_IMAGE_RAM_DISABLE
#define GFX_CONFIG_GRADIENT_DISABLE
#define GFX_CONFIG_PALETTE_DISABLE
#define GFX_CONFIG_FONT_ANTIALIASED_DISABLE
#define GFX_CONFIG_TRANSPARENT_COLOR_DISABLE
#define GFX_CONFIG_PALETTE_EXTERNAL_DISABLE
#define GFX_CONFIG_DOUBLE_BUFFERING_DISABLE
#define GFX_CONFIG_USE_KEYBOARD_DISABLE
#define GFX_CONFIG_USE_TOUCHSCREEN_DISABLE
#define GFX_CONFIG_FOCUS_DISABLE
#define GFX_malloc(size)                                    malloc(size)
#define GFX_free(pObj)                                      free(pObj)


#endif // _SYSTEM_CONFIG_H
/*******************************************************************************
 End of File
*/




//以下、system_definition.h
//-----------------------------------------------------------------------------
/*******************************************************************************
  System Definitions

  File Name:
    system_definitions.h

  Summary:
    MPLAB Harmony project system definitions.

  Description:
    This file contains the system-wide prototypes and definitions for an MPLAB
    Harmony project.
 *******************************************************************************/

//DOM-IGNORE-BEGIN
/*******************************************************************************
Copyright (c) 2013-2014 released Microchip Technology Inc.  All rights reserved.

Microchip licenses to you the right to use, modify, copy and distribute
Software only when embedded on a Microchip microcontroller or digital signal
controller that is integrated into your product or third party product
(pursuant to the sublicense terms in the accompanying license agreement).

You should refer to the license agreement accompanying this Software for
additional information regarding your rights and obligations.

SOFTWARE AND DOCUMENTATION ARE PROVIDED AS IS WITHOUT WARRANTY OF ANY KIND,
EITHER EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION, ANY WARRANTY OF
MERCHANTABILITY, TITLE, NON-INFRINGEMENT AND FITNESS FOR A PARTICULAR PURPOSE.
IN NO EVENT SHALL MICROCHIP OR ITS LICENSORS BE LIABLE OR OBLIGATED UNDER
CONTRACT, NEGLIGENCE, STRICT LIABILITY, CONTRIBUTION, BREACH OF WARRANTY, OR
OTHER LEGAL EQUITABLE THEORY ANY DIRECT OR INDIRECT DAMAGES OR EXPENSES
INCLUDING BUT NOT LIMITED TO ANY INCIDENTAL, SPECIAL, INDIRECT, PUNITIVE OR
CONSEQUENTIAL DAMAGES, LOST PROFITS OR LOST DATA, COST OF PROCUREMENT OF
SUBSTITUTE GOODS, TECHNOLOGY, SERVICES, OR ANY CLAIMS BY THIRD PARTIES
(INCLUDING BUT NOT LIMITED TO ANY DEFENSE THEREOF), OR OTHER SIMILAR COSTS.
 *******************************************************************************/
//DOM-IGNORE-END

#ifndef _SYS_DEFINITIONS_H
#define _SYS_DEFINITIONS_H


// *****************************************************************************
// *****************************************************************************
// Section: Included Files
// *****************************************************************************
// *****************************************************************************

#include <stdint.h>
#include <stddef.h>
#include <stdbool.h>
#include "system/common/sys_common.h"
#include "system/common/sys_module.h"
#include "system/clk/sys_clk.h"
#include "system/clk/sys_clk_static.h"
#include "system/devcon/sys_devcon.h"
#include "system/console/sys_console.h"
#include "framework/driver/pmp/drv_pmp_static.h"
#include "system/ports/sys_ports.h"
#include "gfx/gfx.h"
#include "gfx/gfx_gol.h"
#include "gfx/gfx_gol_scheme.h"
#include "driver/gfx/controller/ssd1926/drv_gfx_ssd1926.h"
#include "system/debug/sys_debug.h"
#include "system/command/sys_command.h"


#include "gfx_hgc_definitions.h"
#include "app.h"


// *****************************************************************************
// *****************************************************************************
// Section: Type Definitions
// *****************************************************************************
// *****************************************************************************

// *****************************************************************************
/* System Objects

  Summary:
    Structure holding the system's object handles

  Description:
    This structure contains the object handles for all objects in the
    MPLAB Harmony project's system configuration.

  Remarks:
    These handles are returned from the "Initialize" functions for each module
    and must be passed into the "Tasks" function for each module.
*/

typedef struct
{
    SYS_MODULE_OBJ  sysDevcon;
    SYS_MODULE_OBJ  gfxObject0;

} SYSTEM_OBJECTS;


// *****************************************************************************
// *****************************************************************************
// Section: extern declarations
// *****************************************************************************
// *****************************************************************************

extern SYSTEM_OBJECTS sysObj;

extern void GFX_TCON_SSD1289Init(void);



 
//// Definitions for reset pin PIC32MZ    //RG12 <-- RB11
#define DisplayResetConfig()        TRISGCLR = _TRISG_TRISG12_MASK
#define DisplayResetEnable()        LATGCLR = _LATG_LATG12_MASK
#define DisplayResetDisable()       LATGSET = _LATG_LATG12_MASK

//#define DisplayResetConfig()        TRISBCLR = _TRISB_TRISB11_MASK
//#define DisplayResetEnable()        LATBCLR = _LATB_LATB11_MASK
//#define DisplayResetDisable()       LATBSET = _LATB_LATB11_MASK


//// Definitions for RS pin PIC32MZ       //RG13 <-- RB12
#define DisplayCmdDataConfig()      TRISGCLR = _TRISG_TRISG13_MASK
#define DisplaySetCommand()         LATGCLR = _LATG_LATG13_MASK
#define DisplaySetData()            LATGSET = _LATG_LATG13_MASK

//#define DisplayCmdDataConfig()      TRISBCLR = _TRISB_TRISB12_MASK
//#define DisplaySetCommand()         LATBCLR = _LATB_LATB12_MASK
//#define DisplaySetData()            LATBSET = _LATB_LATB12_MASK



//// Definitions for CS pin PIC32MZ     //RG14 <-- RJ5
#define DisplayConfig()             TRISGCLR = _TRISG_TRISG14_MASK
#define DisplayEnable()             LATGCLR = _LATG_LATG14_MASK
#define DisplayDisable()            LATGSET = _LATG_LATG14_MASK

//#define DisplayConfig()             TRISJCLR = _TRISJ_TRISJ5_MASK
//#define DisplayEnable()             LATJCLR = _LATJ_LATJ5_MASK
//#define DisplayDisable()            LATJSET = _LATJ_LATJ5_MASK




// Definitions for backlight control pin PIC32MZ
#define DisplayBacklightConfig()    
#define DisplayBacklightOn()       
#define DisplayBacklightOff()    



/*
// Definitions for backlight control pin PIC32MZ
#define DisplayBacklightConfig()    (TRISJbits.TRISJ6 = 0)
#define DisplayBacklightOn()        (LATJbits.LATJ6 = BACKLIGHT_ENABLE_LEVEL)
#define DisplayBacklightOff()       (LATJbits.LATJ6 = BACKLIGHT_DISABLE_LEVEL)
*/

// Definitions for FLASH CS pin
#define DisplayFlashConfig()
#define DisplayFlashEnable()
#define DisplayFlashDisable()

// Definitions for POWER ON pin
#define DisplayPowerConfig()
#define DisplayPowerOn()
#define DisplayPowerOff()

// ADC channel constants
// resistive touch X and Y voltage sensing
#define ADC_XPOS                 (0xB << _AD1CHS_CH0SA_POSITION)
#define ADC_YPOS                 (0xA << _AD1CHS_CH0SA_POSITION)


#define ADPCFG_XPOS              AD1PCFGbits.PCFG11
#define ADPCFG_YPOS              AD1PCFGbits.PCFG10
#define RESISTIVETOUCH_ANALOG  0
#define RESISTIVETOUCH_DIGITAL 1

#define ResistiveTouchScreen_XMinus_Drive_High()        LATDbits.LATD9   = 1
#define ResistiveTouchScreen_XMinus_Drive_Low()         LATDbits.LATD9   = 0
#define ResistiveTouchScreen_XMinus_Config_As_Input()   TRISDbits.TRISD9 = 1
#define ResistiveTouchScreen_XMinus_Config_As_Output()  TRISDbits.TRISD9 = 0

#define ResistiveTouchScreen_YMinus_Drive_High()        LATDbits.LATD8    = 1
#define ResistiveTouchScreen_YMinus_Drive_Low()         LATDbits.LATD8    = 0
#define ResistiveTouchScreen_YMinus_Config_As_Input()   TRISDbits.TRISD8  = 1
#define ResistiveTouchScreen_YMinus_Config_As_Output()  TRISDbits.TRISD8  = 0

// X port definitions
#define ResistiveTouchScreen_XPlus_Drive_High()             LATBbits.LATB11   = 1
#define ResistiveTouchScreen_XPlus_Drive_Low()              LATBbits.LATB11   = 0
#define ResistiveTouchScreen_XPlus_Config_As_Input()        TRISBbits.TRISB11 = 1
#define ResistiveTouchScreen_XPlus_Config_As_Output()       TRISBbits.TRISB11 = 0

// Y port definitions
#define ResistiveTouchScreen_YPlus_Drive_High()             LATBbits.LATB10   = 1
#define ResistiveTouchScreen_YPlus_Drive_Low()              LATBbits.LATB10   = 0
#define ResistiveTouchScreen_YPlus_Config_As_Input()        TRISBbits.TRISB10 = 1
#define ResistiveTouchScreen_YPlus_Config_As_Output()       TRISBbits.TRISB10 = 0


// Potentiometer and Temperature sensor
#define ADC_TEMP                 ADC_CH0_POS_SAMPLEA_AN4
#define TOUCH_ADC_INPUT_SEL   AD1CHS

// ADC Sample Start
#define TOUCH_ADC_START   AD1CON1bits.SAMP

// ADC Status
#define TOUCH_ADC_DONE   AD1CON1bits.DONE

#define ADDRESS_RESISTIVE_TOUCH_VERSION (unsigned long)0xFFFFFFFE
#define ADDRESS_RESISTIVE_TOUCH_ULX   (unsigned long)0xFFFFFFFC
#define ADDRESS_RESISTIVE_TOUCH_ULY   (unsigned long)0xFFFFFFFA
#define ADDRESS_RESISTIVE_TOUCH_URX   (unsigned long)0xFFFFFFF8
#define ADDRESS_RESISTIVE_TOUCH_URY   (unsigned long)0xFFFFFFF6

#define ADDRESS_RESISTIVE_TOUCH_LLX   (unsigned long)0xFFFFFFF4
#define ADDRESS_RESISTIVE_TOUCH_LLY   (unsigned long)0xFFFFFFF2
#define ADDRESS_RESISTIVE_TOUCH_LRX   (unsigned long)0xFFFFFFF0
#define ADDRESS_RESISTIVE_TOUCH_LRY   (unsigned long)0xFFFFFFEE

#define SST25_CS_TRIS   TRISDbits.TRISD1
#define SST25_CS_LAT    LATDbits.LATD1

#define SST25_SCK_TRIS  TRISGbits.TRISG6
#define SST25_SDO_TRIS  TRISGbits.TRISG8
#define SST25_SDI_TRIS  TRISGbits.TRISG7

#define USE_GFX_PMP
#define PMP_DATA_SETUP_TIME                (18)
#define PMP_DATA_WAIT_TIME                 (82)  // based on the minimum pulse width requirement of CS signal of SSD1926
#define PMP_DATA_HOLD_TIME                 (0)




#endif /* _SYS_DEFINITIONS_H */
/*******************************************************************************
 End of File
*/



//以下、system_init.c
//--------------------------------------------------------------------------------------
/*******************************************************************************
  System Initialization File

  File Name:
    system_init.c

  Summary:
    This file contains source code necessary to initialize the system.

  Description:
    This file contains source code necessary to initialize the system.  It
    implements the "SYS_Initialize" function, defines the configuration bits, 
    and allocates any necessary global system resources, such as the 
    sysObj structure that contains the object handles to all the MPLAB Harmony 
    module objects in the system.
 *******************************************************************************/

// DOM-IGNORE-BEGIN
/*******************************************************************************
Copyright (c) 2013-2015 released Microchip Technology Inc.  All rights reserved.

Microchip licenses to you the right to use, modify, copy and distribute
Software only when embedded on a Microchip microcontroller or digital signal
controller that is integrated into your product or third party product
(pursuant to the sublicense terms in the accompanying license agreement).

You should refer to the license agreement accompanying this Software for
additional information regarding your rights and obligations.

SOFTWARE AND DOCUMENTATION ARE PROVIDED AS IS WITHOUT WARRANTY OF ANY KIND,
EITHER EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION, ANY WARRANTY OF
MERCHANTABILITY, TITLE, NON-INFRINGEMENT AND FITNESS FOR A PARTICULAR PURPOSE.
IN NO EVENT SHALL MICROCHIP OR ITS LICENSORS BE LIABLE OR OBLIGATED UNDER
CONTRACT, NEGLIGENCE, STRICT LIABILITY, CONTRIBUTION, BREACH OF WARRANTY, OR
OTHER LEGAL EQUITABLE THEORY ANY DIRECT OR INDIRECT DAMAGES OR EXPENSES
INCLUDING BUT NOT LIMITED TO ANY INCIDENTAL, SPECIAL, INDIRECT, PUNITIVE OR
CONSEQUENTIAL DAMAGES, LOST PROFITS OR LOST DATA, COST OF PROCUREMENT OF
SUBSTITUTE GOODS, TECHNOLOGY, SERVICES, OR ANY CLAIMS BY THIRD PARTIES
(INCLUDING BUT NOT LIMITED TO ANY DEFENSE THEREOF), OR OTHER SIMILAR COSTS.
 *******************************************************************************/
// DOM-IGNORE-END


// *****************************************************************************
// *****************************************************************************
// Section: Included Files
// *****************************************************************************
// *****************************************************************************

#include "system_config.h"
#include "system_definitions.h"


// ****************************************************************************
// ****************************************************************************
// Section: Configuration Bits
// ****************************************************************************
// ****************************************************************************
// <editor-fold defaultstate="collapsed" desc="Configuration Bits">

/*** DEVCFG0 ***/

#pragma config DEBUG =      OFF
#pragma config JTAGEN =     OFF
#pragma config ICESEL =     ICS_PGx1
#pragma config TRCEN =      OFF
#pragma config BOOTISA =    MIPS32
#pragma config FECCCON =    OFF_UNLOCKED
#pragma config FSLEEP =     OFF
#pragma config DBGPER =     PG_ALL
#pragma config EJTAGBEN =   NORMAL
#pragma config CP =         OFF

/*** DEVCFG1 ***/

#pragma config FNOSC =      SPLL
#pragma config DMTINTV =    WIN_127_128
#pragma config FSOSCEN =    OFF
#pragma config IESO =       OFF
#pragma config POSCMOD =    OFF
#pragma config OSCIOFNC =   OFF
#pragma config FCKSM =      CSECME
#pragma config WDTPS =      PS1048576
#pragma config WDTSPGM =    STOP
#pragma config FWDTEN =     OFF
#pragma config WINDIS =     NORMAL
#pragma config FWDTWINSZ =  WINSZ_25
#pragma config DMTCNT =     DMT31
#pragma config FDMTEN =     OFF

/*** DEVCFG2 ***/

#pragma config FPLLIDIV =   DIV_3
#pragma config FPLLRNG =    RANGE_5_10_MHZ

#pragma config FPLLICLK = PLL_FRC   //内蔵高速発振器選択    //★★★ バグ有 主発振回路選択の時、FPLLICLK = PLL_POSCではなくFPLLICLK = PLL_FRCを選択する。(at ver.1.33 XC32)
//#pragma config FPLLICLK =   PLL_POSC

#pragma config FPLLMULT =   MUL_50
#pragma config FPLLODIV =   DIV_2
#pragma config UPLLFSEL =   FREQ_24MHZ
#pragma config UPLLEN =     OFF

/*** DEVCFG3 ***/

#pragma config USERID =     0xffff
#pragma config FMIIEN =     ON
#pragma config FETHIO =     ON
#pragma config PGL1WAY =    ON
#pragma config PMDL1WAY =   ON
#pragma config IOL1WAY =    ON
#pragma config FUSBIDIO =   ON

/*** BF1SEQ0 ***/

#pragma config TSEQ =       0xffff
#pragma config CSEQ =       0xffff
// </editor-fold>


// *****************************************************************************
// *****************************************************************************
// Section: Library/Stack Initialization Data
// *****************************************************************************
// *****************************************************************************



// *****************************************************************************
// *****************************************************************************
// Section: Driver Initialization Data
// *****************************************************************************
// *****************************************************************************

//<editor-fold defaultstate="collapsed" desc="DRV_PMP Initialization Data">
// </editor-fold>
//<editor-fold defaultstate="collapsed" desc="DRV_GFX_SSD1926 Initialization Data">

/*** DRV GFX Initialization Data ***/

DRV_GFX_INIT drvGfxInit =
{
    .orientation             = DISP_ORIENTATION,
    .horizontalResolution    = DISP_HOR_RESOLUTION,
    .verticalResolution      = DISP_VER_RESOLUTION,
    .dataWidth               = DISP_DATA_WIDTH,
    .horizontalPulseWidth    = DISP_HOR_PULSE_WIDTH,
    .horizontalBackPorch     = DISP_HOR_BACK_PORCH,
    .horizontalFrontPorch    = DISP_HOR_FRONT_PORCH,
    .verticalPulseWidth      = DISP_VER_PULSE_WIDTH,
    .verticalBackPorch       = DISP_VER_BACK_PORCH,
    .verticalFrontPorch      = DISP_VER_FRONT_PORCH,
    .logicShift              = DISP_INV_LSHIFT,
    .LCDType                 = 1,
    .colorType               = 0,
    .TCON_Init               = TCON_MODULE,
};



// </editor-fold>

// *****************************************************************************
// *****************************************************************************
// Section: System Data
// *****************************************************************************
// *****************************************************************************

/* Structure to hold the object handles for the modules in the system. */
SYSTEM_OBJECTS sysObj;


// *****************************************************************************
// *****************************************************************************
// Section: Module Initialization Data
// *****************************************************************************
// *****************************************************************************

/*** GFX Initialization Data ***/

 const GFX_INIT gfxInit0 =
{
    .drvInitialize    = NULL,
    .drvOpen          = DRV_GFX_SSD1926_Open,
    .drvInterfaceSet  = DRV_GFX_SSD1926_InterfaceSet,
};

/*******************************************************************************
  Device Control System Service Initialization Data
  
  <editor-fold defaultstate="collapsed" 
  desc="Device Control System Service Initialization Data">
*/

const SYS_DEVCON_INIT sysDevconInit =
{
    .moduleInit = {0},
};

// </editor-fold>


// *****************************************************************************
// *****************************************************************************
// Section: Static Initialization Functions
// *****************************************************************************
// *****************************************************************************


// *****************************************************************************
// *****************************************************************************
// Section: System Initialization
// *****************************************************************************
// *****************************************************************************

/*******************************************************************************
  Function:
    void SYS_Initialize ( SYS_INIT_DATA *data )

  Summary:
    Initializes the board, services, drivers, application and other modules.

  Remarks:
    See prototype in system/common/sys_module.h.
 */

void SYS_Initialize ( void* data )
{
    /* Core Processor Initialization */
    SYS_CLK_Initialize( NULL );
    sysObj.sysDevcon = SYS_DEVCON_Initialize(SYS_DEVCON_INDEX_0, (SYS_MODULE_INIT*)&sysDevconInit);
    SYS_DEVCON_PerformanceConfig(SYS_CLK_SystemFrequencyGet());
    SYS_PORTS_Initialize();

    /* Initialize Drivers */


    /*Initialize PMP0 */
    DRV_PMP0_Initialize();
    DRV_PMP0_ModeConfig();

    DRV_GFX_SSD1926_Initialize(GFX_INDEX_0, (SYS_MODULE_INIT*)&drvGfxInit);

    /* Initialize System Services */

    /* Initialize Middleware */

    sysObj.gfxObject0 = GFX_Initialize(GFX_INDEX_0, (SYS_MODULE_INIT *)&gfxInit0);

    /* Initialize the Application */
    APP_Initialize();
}


/*******************************************************************************
 End of File
*/



//以下、gfx_hgc_definitions.c
//-------------------------------------------------------------------------------------------
/*******************************************************************************
  MPLAB Harmony Graphics Composer Generated Implementation File

  File Name:
    gfx_hgc_definitions.c

  Summary:
    Build-time generated implementation from the MPLAB Harmony
    Graphics Composer.

  Description:
    Build-time generated implementation from the MPLAB Harmony
    Graphics Composer.

    Created with MPLAB Harmony Version 1.05
*******************************************************************************/
// DOM-IGNORE-BEGIN
/*******************************************************************************
Copyright (c) 2013-2014 released Microchip Technology Inc.  All rights reserved.

Microchip licenses to you the right to use, modify, copy and distribute
Software only when embedded on a Microchip microcontroller or digital signal
controller that is integrated into your product or third party product
(pursuant to the sublicense terms in the accompanying license agreement).

You should refer to the license agreement accompanying this Software for
additional information regarding your rights and obligations.

SOFTWARE AND DOCUMENTATION ARE PROVIDED AS IS WITHOUT WARRANTY OF ANY KIND,
EITHER EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION, ANY WARRANTY OF
MERCHANTABILITY, TITLE, NON-INFRINGEMENT AND FITNESS FOR A PARTICULAR PURPOSE.
IN NO EVENT SHALL MICROCHIP OR ITS LICENSORS BE LIABLE OR OBLIGATED UNDER
CONTRACT, NEGLIGENCE, STRICT LIABILITY, CONTRIBUTION, BREACH OF WARRANTY, OR
OTHER LEGAL EQUITABLE THEORY ANY DIRECT OR INDIRECT DAMAGES OR EXPENSES
INCLUDING BUT NOT LIMITED TO ANY INCIDENTAL, SPECIAL, INDIRECT, PUNITIVE OR
CONSEQUENTIAL DAMAGES, LOST PROFITS OR LOST DATA, COST OF PROCUREMENT OF
SUBSTITUTE GOODS, TECHNOLOGY, SERVICES, OR ANY CLAIMS BY THIRD PARTIES
(INCLUDING BUT NOT LIMITED TO ANY DEFENSE THEREOF), OR OTHER SIMILAR COSTS.
*******************************************************************************/
// DOM-IGNORE-END

#include "gfx_hgc_definitions.h"

/*** Default GFX GOL Scheme ***/
#define GFX_SCHEMEDEFAULT GOLSchemeDefault
extern GFX_GOL_OBJ_SCHEME GFX_SCHEMEDEFAULT;

/*** HGC-specified GFX GOL Scheme ***/
static GFX_GOL_OBJ_SCHEME *gfxScheme0;

/*** Generated Asset References ***/
extern const GFX_RESOURCE_HDR flower16bit;
extern const GFX_RESOURCE_HDR fireflysung;

/*** Generated ASCII Text Labels ***/
static const GFX_XCHAR staticTextStr_0[] = { 0x31, 0x36, 0x62, 0x69, 0x74, 0x20, 0x42, 0x50, 0x50, 0x0 }; // 16bit BPP
static const GFX_XCHAR staticTextStr_1[] = { 0x48, 0x65, 0x6c, 0x6c, 0x6f, 0x77, 0x20, 0x57, 0x6f, 0x72, 0x6c, 0x64, 0x20, 0x21, 0x21, 0x0 }; // Hellow World !!
/*** HGC Object Global ***/
HGC_OBJECTS hgcObj;
static HGC_STATES hgcState;

/******************************************************************************
  Function:
    HGC_SCREEN_STATES GFX_HGC_GetScreenState ( void )

  Remarks:
    This function returns the screen state
 */
HGC_SCREEN_STATES GFX_HGC_GetScreenState ( void )
{
    return hgcObj.screenState;
}


/******************************************************************************
  Function:
    void GFX_HGC_SetScreenState ( HGC_SCREEN_STATES newState )

  Remarks:
    This function sets the screen state machine to a new state
 */
void GFX_HGC_SetScreenState ( HGC_SCREEN_STATES newState )
{
    hgcObj.prevRefreshState = hgcObj.screenState;
    hgcObj.screenState = newState;
}


/******************************************************************************
  Function:
    void GFX_HGC_Setup ( void )

  Summary:
    This function sets up the GOL message callback and draw callbacks.  
 */
void GFX_HGC_Setup ( void )
{
    GFX_GOL_MessageCallbackSet(GFX_INDEX_0, &GFX_HGC_MessageCallback);
    GFX_GOL_DrawCallbackSet(GFX_INDEX_0, &GFX_HGC_DrawCallback);

    GFX_HGC_InitializeSchemes();

}

/******************************************************************************
  Function:
    void GFX_HGC_Tasks (SYS_MODULE_OBJ gfxObject);

  Summary:
    This function is called in SYS_Tasks.  The intent wait until the GFX library
    is initialized before supplying items to draw
*/
void GFX_HGC_Tasks  (SYS_MODULE_OBJ gfxObject)
{
    switch ( hgcState )
    {
        case HGC_STATE_INIT:
            if (GFX_Status(gfxObject)==SYS_STATUS_READY)
            {
                GFX_HGC_Setup();
                hgcState = HGC_STATE_RUNNING;
            }
            break;

        case HGC_STATE_RUNNING:
            break;

        default:
            break;
    }
}

/******************************************************************************
  Function:
    void GFX_HGC_SchemeCreate ( void )

  Summary:
    Allocates memory for a new scheme
 */
GFX_GOL_OBJ_SCHEME *GFX_HGC_SchemeCreate(void)
{
    GFX_GOL_OBJ_SCHEME  *pTemp;

    pTemp = (GFX_GOL_OBJ_SCHEME *)GFX_malloc(sizeof(GFX_GOL_OBJ_SCHEME));

    if(pTemp != NULL)
    {
        memcpy(pTemp, &GFX_SCHEMEDEFAULT, sizeof(GFX_GOL_OBJ_SCHEME));
    }

    return (pTemp);
}

/******************************************************************************
  Function:
    void GFX_HGC_InitializeSchemes ( void )

  Summary:
    Initializes all HGC-specified schemes
 */
void GFX_HGC_InitializeSchemes( void )
{
    gfxScheme0 = GFX_HGC_SchemeCreate();

#ifndef GFX_CONFIG_ALPHABLEND_DISABLE
    gfxScheme0->AlphaValue =        GFX_SCHEME_ALPHA_0;
#endif
    gfxScheme0->Color0 =            GFX_RGBConvert(GFX_SCHEME_PRIMARY_COLOR_RED_0, GFX_SCHEME_PRIMARY_COLOR_GREEN_0, GFX_SCHEME_PRIMARY_COLOR_BLUE_0);
    gfxScheme0->Color1 =            GFX_RGBConvert(GFX_SCHEME_SECONDARY_COLOR_RED_0, GFX_SCHEME_SECONDARY_COLOR_GREEN_0, GFX_SCHEME_SECONDARY_COLOR_BLUE_0);
    gfxScheme0->ColorDisabled =     GFX_RGBConvert(GFX_SCHEME_DISABLED_COLOR_RED_0, GFX_SCHEME_DISABLED_COLOR_GREEN_0, GFX_SCHEME_DISABLED_COLOR_BLUE_0);
    gfxScheme0->CommonBkColor =     GFX_RGBConvert(GFX_SCHEME_BACKGROUND_COLOR_RED_0, GFX_SCHEME_BACKGROUND_COLOR_GREEN_0, GFX_SCHEME_BACKGROUND_COLOR_BLUE_0);
        gfxScheme0->EmbossSize =        GFX_SCHEME_EMBOSS_SIZE_0;
    gfxScheme0->EmbossDkColor =     GFX_RGBConvert(GFX_SCHEME_EMBOSS_DARK_COLOR_RED_0, GFX_SCHEME_EMBOSS_DARK_COLOR_GREEN_0, GFX_SCHEME_EMBOSS_DARK_COLOR_BLUE_0);
    gfxScheme0->EmbossLtColor =     GFX_RGBConvert(GFX_SCHEME_EMBOSS_LIGHT_COLOR_RED_0, GFX_SCHEME_EMBOSS_LIGHT_COLOR_GREEN_0, GFX_SCHEME_EMBOSS_LIGHT_COLOR_BLUE_0);
        gfxScheme0->TextColor0 =        GFX_RGBConvert(GFX_SCHEME_TEXT_PRIMARY_COLOR_RED_0, GFX_SCHEME_TEXT_PRIMARY_COLOR_GREEN_0, GFX_SCHEME_TEXT_PRIMARY_COLOR_BLUE_0);
    gfxScheme0->TextColor1 =        GFX_RGBConvert(GFX_SCHEME_TEXT_SECONDARY_COLOR_RED_0, GFX_SCHEME_TEXT_SECONDARY_COLOR_GREEN_0, GFX_SCHEME_TEXT_SECONDARY_COLOR_BLUE_0);
    gfxScheme0->TextColorDisabled = GFX_RGBConvert(GFX_SCHEME_TEXT_DISABLED_COLOR_RED_0, GFX_SCHEME_TEXT_DISABLED_COLOR_GREEN_0, GFX_SCHEME_TEXT_DISABLED_COLOR_BLUE_0);
#ifndef GFX_CONFIG_GRADIENT_DISABLE
        gfxScheme0->gradientStartColor = GFX_RGBConvert(GFX_SCHEME_GRADIENT_START_COLOR_RED_0, GFX_SCHEME_GRADIENT_START_COLOR_GREEN_0, GFX_SCHEME_GRADIENT_START_COLOR_BLUE_0);
        gfxScheme0->gradientEndColor = GFX_RGBConvert(GFX_SCHEME_GRADIENT_END_COLOR_RED_0, GFX_SCHEME_GRADIENT_END_COLOR_GREEN_0, GFX_SCHEME_GRADIENT_END_COLOR_BLUE_0);
#endif
    gfxScheme0->CommonBkLeft =      GFX_SCHEME_BACKGROUND_OFFSET_TOP_0;
    gfxScheme0->CommonBkTop =       GFX_SCHEME_BACKGROUND_OFFSET_LEFT_0;
    gfxScheme0->pFont =             (GFX_RESOURCE_HDR*)&fireflysung;
    gfxScheme0->pCommonBkImage =    (GFX_RESOURCE_HDR*)NULL;
        
        gfxScheme0->fillStyle =         GFX_SCHEME_FILL_STYLE_0;
        gfxScheme0->CommonBkType =      GFX_SCHEME_BACKGROUND_TYPE_0;

}

/******************************************************************************
  Function: 
    bool GFX_HGC_MESSAGECallback(uint16_t objMsg, GFX_GOL_OBJ_HEADER* pObj, GFX_GOL_MESSAGE* pMsg)

  Input: 
    objMsg - translated message for the object,
    pObj - pointer to the object,
    pMsg - pointer to the non-translated, raw GOL message

  Output: 
    If the function returns non-zero the message will be processed by default

  Remarks: 
    GFX_GOL_MESSAGECallback() function calls it each time the valid message for the GOL object is received.
 */
bool GFX_HGC_MessageCallback(GFX_GOL_TRANSLATED_ACTION objMsg, GFX_GOL_OBJ_HEADER *pObj, GFX_GOL_MESSAGE *pMsg)
{
    // process messages for demo screens
    switch (hgcObj.screenState)
    {
        case HGC_SCREEN_STATE_DISPLAY_SCREEN_screen1:
            if (GFX_HGC_MsgPictures(objMsg, pObj) == true)
                return true;
            if (GFX_HGC_MsgStaticTexts(objMsg, pObj) == true)
                return true;
            break;
        case HGC_SCREEN_STATE_DISPLAY_SCREEN_screen2:
            if (GFX_HGC_MsgPictures(objMsg, pObj) == true)
                return true;
            if (GFX_HGC_MsgStaticTexts(objMsg, pObj) == true)
                return true;
            break;
        case HGC_SCREEN_STATE_DISPLAY_SCREEN_screen3:
            if (GFX_HGC_MsgPictures(objMsg, pObj) == true)
                return true;
            if (GFX_HGC_MsgStaticTexts(objMsg, pObj) == true)
                return true;
            break;
        case HGC_SCREEN_STATE_DISPLAY_SCREEN_screen4:
            if (GFX_HGC_MsgPictures(objMsg, pObj) == true)
                return true;
            if (GFX_HGC_MsgStaticTexts(objMsg, pObj) == true)
                return true;
            break;
      default:
            // process message by default
            return true;
    }
    return true;
}

/******************************************************************************
  Function: 
    bool GFX_HGC_DrawCallback( void )

  Output: 
    If the function returns non-zero the draw control will be passed to GOL

  Remarks: 
    GFX_GOL_Draw() function calls it each time when GOL objects drawing is 
    completed. HGC-specified draw data is grouped by screens states. It takes 
    two states to complete the drawing of each screen.  GFX GOL objects are drawn
    first and then GFX Primitives are drawn next to ensure primitives are not
    covered by GOL objects.
 */
bool GFX_HGC_DrawCallback( void )
{
    switch (hgcObj.screenState)
    {
        case HGC_SCREEN_STATE_INIT:
            //Draw the primary screen as selected in the Composer
            GFX_HGC_SetScreenState(HGC_SCREEN_STATE_SETUP_SCREEN_screen1);
            return true;
        case HGC_SCREEN_STATE_SETUP_SCREEN_screen1:
            GFX_HGC_SetScreenState(HGC_SCREEN_STATE_PRE_DRAW_GOL_SCREEN_screen1);
            break;
        case HGC_SCREEN_STATE_PRE_DRAW_GOL_SCREEN_screen1:
            GFX_HGC_SetScreenState(HGC_SCREEN_STATE_DRAW_GOL_SCREEN_screen1);
            break;
        case HGC_SCREEN_STATE_DRAW_GOL_SCREEN_screen1:
            GFX_HGC_SetupScreen(screen1);
            GFX_HGC_DrawScreen_GOL(screen1);
            GFX_HGC_SetScreenState(HGC_SCREEN_STATE_POST_DRAW_GOL_SCREEN_screen1);
            break;
        case HGC_SCREEN_STATE_POST_DRAW_GOL_SCREEN_screen1:
            GFX_HGC_SetScreenState(HGC_SCREEN_STATE_PRE_DRAW_PRIMITIVE_SCREEN_screen1);
            break;
        case HGC_SCREEN_STATE_PRE_DRAW_PRIMITIVE_SCREEN_screen1:
            GFX_HGC_SetScreenState(HGC_SCREEN_STATE_DRAW_PRIMITIVE_SCREEN_screen1);
            break;
        case HGC_SCREEN_STATE_DRAW_PRIMITIVE_SCREEN_screen1:
            GFX_HGC_DrawScreen_Primitives(screen1);
            GFX_HGC_SetScreenState(HGC_SCREEN_STATE_POST_DRAW_PRIMITIVE_SCREEN_screen1);
            break;
        case HGC_SCREEN_STATE_POST_DRAW_PRIMITIVE_SCREEN_screen1:
            GFX_HGC_SetScreenState(HGC_SCREEN_STATE_DISPLAY_SCREEN_screen1);
            break;
        case HGC_SCREEN_STATE_DISPLAY_SCREEN_screen1:
            break;
        case HGC_SCREEN_STATE_SETUP_SCREEN_screen2:
            GFX_HGC_SetScreenState(HGC_SCREEN_STATE_PRE_DRAW_GOL_SCREEN_screen2);
            break;
        case HGC_SCREEN_STATE_PRE_DRAW_GOL_SCREEN_screen2:
            GFX_HGC_SetScreenState(HGC_SCREEN_STATE_DRAW_GOL_SCREEN_screen2);
            break;
        case HGC_SCREEN_STATE_DRAW_GOL_SCREEN_screen2:
            GFX_HGC_SetupScreen(screen2);
            GFX_HGC_DrawScreen_GOL(screen2);
            GFX_HGC_SetScreenState(HGC_SCREEN_STATE_POST_DRAW_GOL_SCREEN_screen2);
            break;
        case HGC_SCREEN_STATE_POST_DRAW_GOL_SCREEN_screen2:
            GFX_HGC_SetScreenState(HGC_SCREEN_STATE_PRE_DRAW_PRIMITIVE_SCREEN_screen2);
            break;
        case HGC_SCREEN_STATE_PRE_DRAW_PRIMITIVE_SCREEN_screen2:
            GFX_HGC_SetScreenState(HGC_SCREEN_STATE_DRAW_PRIMITIVE_SCREEN_screen2);
            break;
        case HGC_SCREEN_STATE_DRAW_PRIMITIVE_SCREEN_screen2:
            GFX_HGC_DrawScreen_Primitives(screen2);
            GFX_HGC_SetScreenState(HGC_SCREEN_STATE_POST_DRAW_PRIMITIVE_SCREEN_screen2);
            break;
        case HGC_SCREEN_STATE_POST_DRAW_PRIMITIVE_SCREEN_screen2:
            GFX_HGC_SetScreenState(HGC_SCREEN_STATE_DISPLAY_SCREEN_screen2);
            break;
        case HGC_SCREEN_STATE_DISPLAY_SCREEN_screen2:
            break;
        case HGC_SCREEN_STATE_SETUP_SCREEN_screen3:
            GFX_HGC_SetScreenState(HGC_SCREEN_STATE_PRE_DRAW_GOL_SCREEN_screen3);
            break;
        case HGC_SCREEN_STATE_PRE_DRAW_GOL_SCREEN_screen3:
            GFX_HGC_SetScreenState(HGC_SCREEN_STATE_DRAW_GOL_SCREEN_screen3);
            break;
        case HGC_SCREEN_STATE_DRAW_GOL_SCREEN_screen3:
            GFX_HGC_SetupScreen(screen3);
            GFX_HGC_DrawScreen_GOL(screen3);
            GFX_HGC_SetScreenState(HGC_SCREEN_STATE_POST_DRAW_GOL_SCREEN_screen3);
            break;
        case HGC_SCREEN_STATE_POST_DRAW_GOL_SCREEN_screen3:
            GFX_HGC_SetScreenState(HGC_SCREEN_STATE_PRE_DRAW_PRIMITIVE_SCREEN_screen3);
            break;
        case HGC_SCREEN_STATE_PRE_DRAW_PRIMITIVE_SCREEN_screen3:
            GFX_HGC_SetScreenState(HGC_SCREEN_STATE_DRAW_PRIMITIVE_SCREEN_screen3);
            break;
        case HGC_SCREEN_STATE_DRAW_PRIMITIVE_SCREEN_screen3:
            GFX_HGC_DrawScreen_Primitives(screen3);
            GFX_HGC_SetScreenState(HGC_SCREEN_STATE_POST_DRAW_PRIMITIVE_SCREEN_screen3);
            break;
        case HGC_SCREEN_STATE_POST_DRAW_PRIMITIVE_SCREEN_screen3:
            GFX_HGC_SetScreenState(HGC_SCREEN_STATE_DISPLAY_SCREEN_screen3);
            break;
        case HGC_SCREEN_STATE_DISPLAY_SCREEN_screen3:
            break;
        case HGC_SCREEN_STATE_SETUP_SCREEN_screen4:
            GFX_HGC_SetScreenState(HGC_SCREEN_STATE_PRE_DRAW_GOL_SCREEN_screen4);
            break;
        case HGC_SCREEN_STATE_PRE_DRAW_GOL_SCREEN_screen4:
            GFX_HGC_SetScreenState(HGC_SCREEN_STATE_DRAW_GOL_SCREEN_screen4);
            break;
        case HGC_SCREEN_STATE_DRAW_GOL_SCREEN_screen4:
            GFX_HGC_SetupScreen(screen4);
            GFX_HGC_DrawScreen_GOL(screen4);
            GFX_HGC_SetScreenState(HGC_SCREEN_STATE_POST_DRAW_GOL_SCREEN_screen4);
            break;
        case HGC_SCREEN_STATE_POST_DRAW_GOL_SCREEN_screen4:
            GFX_HGC_SetScreenState(HGC_SCREEN_STATE_PRE_DRAW_PRIMITIVE_SCREEN_screen4);
            break;
        case HGC_SCREEN_STATE_PRE_DRAW_PRIMITIVE_SCREEN_screen4:
            GFX_HGC_SetScreenState(HGC_SCREEN_STATE_DRAW_PRIMITIVE_SCREEN_screen4);
            break;
        case HGC_SCREEN_STATE_DRAW_PRIMITIVE_SCREEN_screen4:
            GFX_HGC_DrawScreen_Primitives(screen4);
            GFX_HGC_SetScreenState(HGC_SCREEN_STATE_POST_DRAW_PRIMITIVE_SCREEN_screen4);
            break;
        case HGC_SCREEN_STATE_POST_DRAW_PRIMITIVE_SCREEN_screen4:
            GFX_HGC_SetScreenState(HGC_SCREEN_STATE_DISPLAY_SCREEN_screen4);
            break;
        case HGC_SCREEN_STATE_DISPLAY_SCREEN_screen4:
            break;
        default:
            return true; // release drawing control to GOL by default
    }

    return true; // release drawing control to GOL
}

/******************************************************************************
  Function: 
    void GFX_HGC_SetupScreen( uint8_t  screenId )

  Remarks: 
    Clears current screen and starts a fresh screen with its background color
 */
void GFX_HGC_SetupScreen(uint8_t screenId)
{
    switch (screenId)
    {
        case screen1:
            GFX_ColorSet(GFX_INDEX_0, GFX_RGBConvert(0x00, 0x00, 0x00));
            GFX_ScreenClear(GFX_INDEX_0);

            GFX_GOL_ObjectListFree(GFX_INDEX_0); // free memory for the objects in the previous linked list and start new list
            break;
        case screen2:
            GFX_ColorSet(GFX_INDEX_0, GFX_RGBConvert(0x00, 0x00, 0x00));
            GFX_ScreenClear(GFX_INDEX_0);

            GFX_GOL_ObjectListFree(GFX_INDEX_0); // free memory for the objects in the previous linked list and start new list
            break;
        case screen3:
            GFX_ColorSet(GFX_INDEX_0, GFX_RGBConvert(0x00, 0x00, 0x00));
            GFX_ScreenClear(GFX_INDEX_0);

            GFX_GOL_ObjectListFree(GFX_INDEX_0); // free memory for the objects in the previous linked list and start new list
            break;
        case screen4:
            GFX_ColorSet(GFX_INDEX_0, GFX_RGBConvert(0x00, 0xFC, 0x00));
            GFX_ScreenClear(GFX_INDEX_0);

            GFX_GOL_ObjectListFree(GFX_INDEX_0); // free memory for the objects in the previous linked list and start new list
            break;
        default:
            break;
    }
}


/******************************************************************************
  Function: 
    bool GFX_HGC_ChangeScreen( uint8_t  screenId )

  Output: 
    Returns true if a screenId matches an existing screen identifier

  Remarks: 
    Can be called to initiate GFX Library to draw a new screen
 */
bool GFX_HGC_ChangeScreen(uint8_t screenId)
{
    switch (screenId)
    {
        case screen1:
            GFX_HGC_SetScreenState(HGC_SCREEN_STATE_SETUP_SCREEN_screen1);
            break;
        case screen2:
            GFX_HGC_SetScreenState(HGC_SCREEN_STATE_SETUP_SCREEN_screen2);
            break;
        case screen3:
            GFX_HGC_SetScreenState(HGC_SCREEN_STATE_SETUP_SCREEN_screen3);
            break;
        case screen4:
            GFX_HGC_SetScreenState(HGC_SCREEN_STATE_SETUP_SCREEN_screen4);
            break;
        default:
            return false;
    }

    return true; // release drawing control to GOL
}

/******************************************************************************
  Function: 
    bool GFX_HGC_DrawScreen_GOL( uint8_t  screenId )

  Output: 
    Returns true if a screenId matches an existing screen identifier

  Remarks: 
    HGC-specified GFX GOL objects are drawn here, grouped by screen.
    The draw order is reverse Z-ordered.
 */
bool GFX_HGC_DrawScreen_GOL(uint8_t screenId)
{
    switch (screenId)
    {
        case screen1:
            break;
        case screen2:
            GFX_HGC_DrawItem(Picture1);
            GFX_HGC_DrawItem(StaticText1);
            break;
        case screen3:
            break;
        case screen4:
            GFX_HGC_DrawItem(StaticText2);
            break;
        default:
            return false;
    }

    return true; // release drawing control to GOL
}


/******************************************************************************
  Function: 
    bool GFX_HGC_DrawScreen_Primitives( uint8_t  screenId )

  Output:
    Returns true if a screenId matches an existing screen identifier

  Remarks: 
    HGC-specified GFX Primitives are drawn here, grouped by screen.
    GFX Primitives are drawn after GFX GOL Objects to make sure GFX GOL Objects
    do not cover GFX Primitives
 */
bool GFX_HGC_DrawScreen_Primitives(uint8_t screenId)
{
    switch (screenId)
    {
        case screen1:
            GFX_HGC_DrawItem(Circle1);
            GFX_HGC_DrawItem(Circle2);
            GFX_HGC_DrawItem(Circle3);
            GFX_HGC_DrawItem(Circle4);
            GFX_HGC_DrawItem(Circle5);
            GFX_HGC_DrawItem(Circle6);
            GFX_HGC_DrawItem(Circle7);
            GFX_HGC_DrawItem(Circle8);
            GFX_HGC_DrawItem(Circle9);
            GFX_HGC_DrawItem(Circle10);
            GFX_HGC_DrawItem(Line1);
            GFX_HGC_DrawItem(Line2);
            GFX_HGC_DrawItem(Line3);
            GFX_HGC_DrawItem(Line4);
            GFX_HGC_DrawItem(Line5);
            GFX_HGC_DrawItem(Line6);
            GFX_HGC_DrawItem(Line7);
            GFX_HGC_DrawItem(Line8);
            GFX_HGC_DrawItem(Line9);
            GFX_HGC_DrawItem(Line10);
            GFX_HGC_DrawItem(Line11);
            break;
        case screen2:
            break;
        case screen3:
            GFX_HGC_DrawItem(Rectangle2);
            GFX_HGC_DrawItem(Rectangle3);
            GFX_HGC_DrawItem(Rectangle1);
            GFX_HGC_DrawItem(Rectangle4);
            GFX_HGC_DrawItem(Rectangle5);
            break;
        case screen4:
            break;
        default:
            return true;
    }

    return true; // release drawing control to GOL
}


/******************************************************************************
  Function: 
    bool GFX_HGC_DrawItem(int itemId)

  Output:
    Returns true if a itemId matches an existing item identifier

  Remarks: 
    Every item specified in every screen in HGC is listed in this function
 */
bool GFX_HGC_DrawItem(int itemId)
{
    switch(itemId)
    {
    case StaticText1:
        hgcObj.pStaticText1Obj = GFX_GOL_StaticTextCreate
                (
                 GFX_INDEX_0,
                 StaticText1,      // button ID
                 GFX_STATICTEXT_LEFT_0,    // left
                 GFX_STATICTEXT_TOP_0,     // top
                 GFX_STATICTEXT_RIGHT_0,   // right
                 GFX_STATICTEXT_BOTTOM_0,  // bottom
                 GFX_STATICTEXT_STATE_0,   // state
                 (GFX_XCHAR*)staticTextStr_0,    // text
                 GFX_STATICTEXT_ALIGNMENT_0,       //alignment
                 GFX_STATICTEXT_SCHEME_0
                 ); // use alternate scheme
        break;
    case StaticText2:
        hgcObj.pStaticText2Obj = GFX_GOL_StaticTextCreate
                (
                 GFX_INDEX_0,
                 StaticText2,      // button ID
                 GFX_STATICTEXT_LEFT_1,    // left
                 GFX_STATICTEXT_TOP_1,     // top
                 GFX_STATICTEXT_RIGHT_1,   // right
                 GFX_STATICTEXT_BOTTOM_1,  // bottom
                 GFX_STATICTEXT_STATE_1,   // state
                 (GFX_XCHAR*)staticTextStr_1,    // text
                 GFX_STATICTEXT_ALIGNMENT_1,       //alignment
                 GFX_STATICTEXT_SCHEME_1
                 ); // use alternate scheme
        break;
    case Picture1:
        hgcObj.pPicture1Obj = GFX_GOL_PictureControlCreate
                (
                 GFX_INDEX_0,
                 Picture1,      // picture ID
                 GFX_PICTURE_LEFT_0,    // left
                 GFX_PICTURE_TOP_0,     // top
                 GFX_PICTURE_RIGHT_0,   // right                                 
                 GFX_PICTURE_BOTTOM_0,  // bottom
                                 GFX_PICTURE_STATE_0,   // state                 
                 GFX_PICTURE_SCALE_0,     // scale
                 (GFX_RESOURCE_HDR*)&flower16bit,    // bitmap
                 GFX_PICTURE_SCHEME_0
                 );
        break;
                case Line11:
                {
                        GFX_ColorSet(GFX_INDEX_0, GFX_RGBConvert(0xF8, 0xFC, 0xF8));
                        GFX_LineStyleSet(GFX_INDEX_0, GFX_LINE_STYLE_THIN_SOLID);
                        GFX_LineDraw(GFX_INDEX_0,
                                                 267,  // p1x
                                                 0,  // p1y
                                                 53,  // p2x
                                                 239); // p2y
                        break;
                }               
                case Line10:
                {
                        GFX_ColorSet(GFX_INDEX_0, GFX_RGBConvert(0xF8, 0xFC, 0xF8));
                        GFX_LineStyleSet(GFX_INDEX_0, GFX_LINE_STYLE_THIN_SOLID);
                        GFX_LineDraw(GFX_INDEX_0,
                                                 214,  // p1x
                                                 0,  // p1y
                                                 106,  // p2x
                                                 239); // p2y
                        break;
                }               
                case Line9:
                {
                        GFX_ColorSet(GFX_INDEX_0, GFX_RGBConvert(0xF8, 0xFC, 0xF8));
                        GFX_LineStyleSet(GFX_INDEX_0, GFX_LINE_STYLE_THIN_SOLID);
                        GFX_LineDraw(GFX_INDEX_0,
                                                 106,  // p1x
                                                 0,  // p1y
                                                 214,  // p2x
                                                 239); // p2y
                        break;
                }               
                case Line8:
                {
                        GFX_ColorSet(GFX_INDEX_0, GFX_RGBConvert(0xF8, 0xFC, 0xF8));
                        GFX_LineStyleSet(GFX_INDEX_0, GFX_LINE_STYLE_THIN_SOLID);
                        GFX_LineDraw(GFX_INDEX_0,
                                                 53,  // p1x
                                                 0,  // p1y
                                                 267,  // p2x
                                                 239); // p2y
                        break;
                }               
                case Line7:
                {
                        GFX_ColorSet(GFX_INDEX_0, GFX_RGBConvert(0xF8, 0xFC, 0xF8));
                        GFX_LineStyleSet(GFX_INDEX_0, GFX_LINE_STYLE_THIN_SOLID);
                        GFX_LineDraw(GFX_INDEX_0,
                                                 160,  // p1x
                                                 0,  // p1y
                                                 160,  // p2x
                                                 239); // p2y
                        break;
                }               
                case Line6:
                {
                        GFX_ColorSet(GFX_INDEX_0, GFX_RGBConvert(0xF8, 0xFC, 0xF8));
                        GFX_LineStyleSet(GFX_INDEX_0, GFX_LINE_STYLE_THIN_SOLID);
                        GFX_LineDraw(GFX_INDEX_0,
                                                 0,  // p1x
                                                 239,  // p1y
                                                 319,  // p2x
                                                 0); // p2y
                        break;
                }               
                case Line5:
                {
                        GFX_ColorSet(GFX_INDEX_0, GFX_RGBConvert(0xF8, 0xFC, 0xF8));
                        GFX_LineStyleSet(GFX_INDEX_0, GFX_LINE_STYLE_THIN_SOLID);
                        GFX_LineDraw(GFX_INDEX_0,
                                                 0,  // p1x
                                                 0,  // p1y
                                                 319,  // p2x
                                                 239); // p2y
                        break;
                }               
                case Line4:
                {
                        GFX_ColorSet(GFX_INDEX_0, GFX_RGBConvert(0x00, 0xFC, 0x00));
                        GFX_LineStyleSet(GFX_INDEX_0, GFX_LINE_STYLE_THIN_SOLID);
                        GFX_LineDraw(GFX_INDEX_0,
                                                 319,  // p1x
                                                 0,  // p1y
                                                 319,  // p2x
                                                 239); // p2y
                        break;
                }               
                case Line3:
                {
                        GFX_ColorSet(GFX_INDEX_0, GFX_RGBConvert(0xF8, 0xFC, 0x00));
                        GFX_LineStyleSet(GFX_INDEX_0, GFX_LINE_STYLE_THIN_SOLID);
                        GFX_LineDraw(GFX_INDEX_0,
                                                 0,  // p1x
                                                 0,  // p1y
                                                 0,  // p2x
                                                 239); // p2y
                        break;
                }               
                case Line2:
                {
                        GFX_ColorSet(GFX_INDEX_0, GFX_RGBConvert(0x00, 0x00, 0xF8));
                        GFX_LineStyleSet(GFX_INDEX_0, GFX_LINE_STYLE_THIN_SOLID);
                        GFX_LineDraw(GFX_INDEX_0,
                                                 0,  // p1x
                                                 239,  // p1y
                                                 319,  // p2x
                                                 239); // p2y
                        break;
                }               
                case Line1:
                {
                        GFX_ColorSet(GFX_INDEX_0, GFX_RGBConvert(0xF8, 0x00, 0x00));
                        GFX_LineStyleSet(GFX_INDEX_0, GFX_LINE_STYLE_THIN_SOLID);
                        GFX_LineDraw(GFX_INDEX_0,
                                                 0,  // p1x
                                                 0,  // p1y
                                                 319,  // p2x
                                                 0); // p2y
                        break;
                }               
                case Rectangle5:
                {
                        GFX_ColorSet(GFX_INDEX_0, GFX_RGBConvert(0x00, 0x00, 0xF8));
                        GFX_LineStyleSet(GFX_INDEX_0, GFX_LINE_STYLE_THIN_SOLID);
                        GFX_RectangleDraw(GFX_INDEX_0,
                                                          65,  // p1x
                                                          30,  // p1y
                                                          255,  // p2x
                                                          210); // p2y
                        
                        break;
                }       
                case Rectangle4:
                {
                        GFX_ColorSet(GFX_INDEX_0, GFX_RGBConvert(0x00, 0x00, 0xF8));
                        GFX_LineStyleSet(GFX_INDEX_0, GFX_LINE_STYLE_THIN_SOLID);
                        GFX_RectangleDraw(GFX_INDEX_0,
                                                          80,  // p1x
                                                          45,  // p1y
                                                          240,  // p2x
                                                          195); // p2y
                        
                        break;
                }       
                case Rectangle1:
                {
                        GFX_FillStyleSet(GFX_INDEX_0, GFX_FILL_STYLE_ALPHA_COLOR);
                        GFX_ColorSet(GFX_INDEX_0, GFX_RGBConvert(0xF8, 0x00, 0x00));
                        GFX_AlphaBlendingValueSet(GFX_INDEX_0, 100);
                        GFX_RectangleFillDraw(GFX_INDEX_0,
                                                                  125,  // p1x
                                                                  90,  // p1y
                                                                  195,  // p2x
                                                                  150); // p2y
                        
                        GFX_ColorSet(GFX_INDEX_0, GFX_RGBConvert(0xF8, 0x00, 0x00));
                        GFX_LineStyleSet(GFX_INDEX_0, GFX_LINE_STYLE_THIN_SOLID);
                        GFX_RectangleDraw(GFX_INDEX_0,
                                                          125,  // p1x
                                                          90,  // p1y
                                                          195,  // p2x
                                                          150); // p2y
                        
                        break;
                }       
                case Rectangle3:
                {
                        GFX_FillStyleSet(GFX_INDEX_0, GFX_FILL_STYLE_COLOR);
                        GFX_ColorSet(GFX_INDEX_0, GFX_RGBConvert(0x00, 0xFC, 0x00));
                        GFX_RectangleFillDraw(GFX_INDEX_0,
                                                                  110,  // p1x
                                                                  75,  // p1y
                                                                  210,  // p2x
                                                                  165); // p2y
                        
                        GFX_ColorSet(GFX_INDEX_0, GFX_RGBConvert(0x00, 0xFC, 0x00));
                        GFX_LineStyleSet(GFX_INDEX_0, GFX_LINE_STYLE_THIN_SOLID);
                        GFX_RectangleDraw(GFX_INDEX_0,
                                                          110,  // p1x
                                                          75,  // p1y
                                                          210,  // p2x
                                                          165); // p2y
                        
                        break;
                }       
                case Rectangle2:
                {
                        GFX_FillStyleSet(GFX_INDEX_0, GFX_FILL_STYLE_COLOR);
                        GFX_ColorSet(GFX_INDEX_0, GFX_RGBConvert(0x00, 0x00, 0xF8));
                        GFX_RectangleFillDraw(GFX_INDEX_0,
                                                                  95,  // p1x
                                                                  60,  // p1y
                                                                  225,  // p2x
                                                                  180); // p2y
                        
                        GFX_ColorSet(GFX_INDEX_0, GFX_RGBConvert(0x00, 0x00, 0xF8));
                        GFX_LineStyleSet(GFX_INDEX_0, GFX_LINE_STYLE_THIN_SOLID);
                        GFX_RectangleDraw(GFX_INDEX_0,
                                                          95,  // p1x
                                                          60,  // p1y
                                                          225,  // p2x
                                                          180); // p2y
                        
                        break;
                }       
                case Circle10:
                {
                        GFX_ColorSet(GFX_INDEX_0,GFX_RGBConvert(0xF8, 0x00, 0x00));
                        GFX_LineStyleSet(GFX_INDEX_0, GFX_LINE_STYLE_THIN_SOLID);
                        GFX_CircleDraw(GFX_INDEX_0,
                                                   160, // p1x
                                                   120, // p1y
                                                   3); // radius
                                                   
                        break;
                }       
                case Circle9:
                {
                        GFX_ColorSet(GFX_INDEX_0,GFX_RGBConvert(0xF8, 0x00, 0x00));
                        GFX_LineStyleSet(GFX_INDEX_0, GFX_LINE_STYLE_THIN_SOLID);
                        GFX_CircleDraw(GFX_INDEX_0,
                                                   160, // p1x
                                                   120, // p1y
                                                   16); // radius
                                                   
                        break;
                }       
                case Circle8:
                {
                        GFX_ColorSet(GFX_INDEX_0,GFX_RGBConvert(0xF8, 0x00, 0x00));
                        GFX_LineStyleSet(GFX_INDEX_0, GFX_LINE_STYLE_THIN_SOLID);
                        GFX_CircleDraw(GFX_INDEX_0,
                                                   160, // p1x
                                                   120, // p1y
                                                   29); // radius
                                                   
                        break;
                }       
                case Circle7:
                {
                        GFX_ColorSet(GFX_INDEX_0,GFX_RGBConvert(0xF8, 0x00, 0x00));
                        GFX_LineStyleSet(GFX_INDEX_0, GFX_LINE_STYLE_THIN_SOLID);
                        GFX_CircleDraw(GFX_INDEX_0,
                                                   160, // p1x
                                                   120, // p1y
                                                   42); // radius
                                                   
                        break;
                }       
                case Circle6:
                {
                        GFX_ColorSet(GFX_INDEX_0,GFX_RGBConvert(0xF8, 0x00, 0x00));
                        GFX_LineStyleSet(GFX_INDEX_0, GFX_LINE_STYLE_THIN_SOLID);
                        GFX_CircleDraw(GFX_INDEX_0,
                                                   160, // p1x
                                                   120, // p1y
                                                   55); // radius
                                                   
                        break;
                }       
                case Circle5:
                {
                        GFX_ColorSet(GFX_INDEX_0,GFX_RGBConvert(0xF8, 0x00, 0x00));
                        GFX_LineStyleSet(GFX_INDEX_0, GFX_LINE_STYLE_THIN_SOLID);
                        GFX_CircleDraw(GFX_INDEX_0,
                                                   160, // p1x
                                                   120, // p1y
                                                   68); // radius
                                                   
                        break;
                }       
                case Circle4:
                {
                        GFX_ColorSet(GFX_INDEX_0,GFX_RGBConvert(0xF8, 0x00, 0x00));
                        GFX_LineStyleSet(GFX_INDEX_0, GFX_LINE_STYLE_THIN_SOLID);
                        GFX_CircleDraw(GFX_INDEX_0,
                                                   160, // p1x
                                                   120, // p1y
                                                   81); // radius
                                                   
                        break;
                }       
                case Circle3:
                {
                        GFX_ColorSet(GFX_INDEX_0,GFX_RGBConvert(0xF8, 0x00, 0x00));
                        GFX_LineStyleSet(GFX_INDEX_0, GFX_LINE_STYLE_THIN_SOLID);
                        GFX_CircleDraw(GFX_INDEX_0,
                                                   160, // p1x
                                                   120, // p1y
                                                   94); // radius
                                                   
                        break;
                }       
                case Circle2:
                {
                        GFX_ColorSet(GFX_INDEX_0,GFX_RGBConvert(0xF8, 0x00, 0x00));
                        GFX_LineStyleSet(GFX_INDEX_0, GFX_LINE_STYLE_THIN_SOLID);
                        GFX_CircleDraw(GFX_INDEX_0,
                                                   160, // p1x
                                                   120, // p1y
                                                   107); // radius
                                                   
                        break;
                }       
                case Circle1:
                {
                        GFX_ColorSet(GFX_INDEX_0,GFX_RGBConvert(0xF8, 0x00, 0x00));
                        GFX_LineStyleSet(GFX_INDEX_0, GFX_LINE_STYLE_THIN_SOLID);
                        GFX_CircleDraw(GFX_INDEX_0,
                                                   160, // p1x
                                                   120, // p1y
                                                   120); // radius
                                                   
                        break;
                }       
        default:
                return false; // process by default
    }

    return true;
}

/******************************************************************************
  Function: 
    bool GFX_HGC_MsgStaticTexts(uint16_t objMsg, GFX_GOL_OBJ_HEADER *pObj)

  Output:
    Returns true if a Object ID matches an existing item identifier

  Remarks: 
    Handles GFX GOL Static Text events
 */
bool GFX_HGC_MsgStaticTexts(uint16_t objMsg, GFX_GOL_OBJ_HEADER *pObj)
{
    switch (GFX_GOL_ObjectIDGet(pObj))
    {
        default:
            return false; // default false as it is not processed
    }    
}

/******************************************************************************
  Function: 
    bool GFX_HGC_MsgPictures(uint16_t objMsg, GFX_GOL_OBJ_HEADER *pObj)

  Output:
    Returns true if a Object ID matches an existing item identifier

  Remarks: 
    Handles GFX GOL Picture Control events
 */
bool GFX_HGC_MsgPictures(uint16_t objMsg, GFX_GOL_OBJ_HEADER *pObj)
{
    switch (GFX_GOL_ObjectIDGet(pObj))
    {
        default:
            return false; // default false as it is not processed
    }    
}
















 <実行結果>
1. ピクチャー
 以下、各画面

   液晶画面 
 @  
 A  
 B  
 C  



2. 動画 ----> You Tube


■ マイクロチップ デモソフト”Primitive”  at PIC32MZ + INT035 

   
  <試作品仕様>
   ・ Harmonyのグラフィックライブラリのサンプルデモソフトとして マイクロチップから提供されている
      ”Primitive"(C:\microchip\harmony\v1_05\apps\gfx\primitive)を
     下記ハードウェアで実行する
      @ PIC: PIC32MZ2048EFH100
      A 液晶: (株)ディスプレーテック INT035-TS QVGA、3.5インチ
   
   ・ 開発環境  Harmony ver.1.06、  XC32 ver.1.40、  MPLABX 3.06  PIC32MZ2048EFH  revison 1
  

  <試作品回路図>(→回路図のPDFファイル


<試作品外観>下記の写真には上記回路図にはない、また本テーマと関係のない部品が多々写っています




    

          

   <プログラム例>

//以下、main.c
//-----------------------------------------------------------------------------------------------



/*******************************************************************************
  MPLAB Harmony Project Main Source File

  Company:
    Microchip Technology Inc.
  
  File Name:
    main.c

  Summary:
    This file contains the "main" function for an MPLAB Harmony project.

  Description:
    This file contains the "main" function for an MPLAB Harmony project.  The
    "main" function calls the "SYS_Initialize" function to initialize the state 
    machines of all MPLAB Harmony modules in the system and it calls the 
    "SYS_Tasks" function from within a system-wide "super" loop to maintain 
    their correct operation. These two functions are implemented in 
    configuration-specific files (usually "system_init.c" and "system_tasks.c")
    in a configuration-specific folder under the "src/system_config" folder 
    within this project's top-level folder.  An MPLAB Harmony project may have
    more than one configuration, each contained within it's own folder under
    the "system_config" folder.
 *******************************************************************************/

// DOM-IGNORE-BEGIN
/*******************************************************************************
Copyright (c) 2013-2014 released Microchip Technology Inc.  All rights reserved.

//Microchip licenses to you the right to use, modify, copy and distribute
Software only when embedded on a Microchip microcontroller or digital signal
controller that is integrated into your product or third party product
(pursuant to the sublicense terms in the accompanying license agreement).

You should refer to the license agreement accompanying this Software for
additional information regarding your rights and obligations.

SOFTWARE AND DOCUMENTATION ARE PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND,
EITHER EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION, ANY WARRANTY OF
MERCHANTABILITY, TITLE, NON-INFRINGEMENT AND FITNESS FOR A PARTICULAR PURPOSE.
IN NO EVENT SHALL MICROCHIP OR ITS LICENSORS BE LIABLE OR OBLIGATED UNDER
CONTRACT, NEGLIGENCE, STRICT LIABILITY, CONTRIBUTION, BREACH OF WARRANTY, OR
OTHER LEGAL EQUITABLE THEORY ANY DIRECT OR INDIRECT DAMAGES OR EXPENSES
INCLUDING BUT NOT LIMITED TO ANY INCIDENTAL, SPECIAL, INDIRECT, PUNITIVE OR
CONSEQUENTIAL DAMAGES, LOST PROFITS OR LOST DATA, COST OF PROCUREMENT OF
SUBSTITUTE GOODS, TECHNOLOGY, SERVICES, OR ANY CLAIMS BY THIRD PARTIES
(INCLUDING BUT NOT LIMITED TO ANY DEFENSE THEREOF), OR OTHER SIMILAR COSTS.
 *******************************************************************************/
// DOM-IGNORE-END


// *****************************************************************************
// *****************************************************************************
// Section: Included Files
// *****************************************************************************
// *****************************************************************************

#include <stddef.h>                     // Defines NULL
#include <stdbool.h>                    // Defines true
#include <stdlib.h>                     // Defines EXIT_FAILURE
#include "system/common/sys_module.h"   // SYS function prototypes


// *****************************************************************************
// *****************************************************************************
// Section: Main Entry Point
// *****************************************************************************
// *****************************************************************************

int main ( void )
{
    /* Initialize all MPLAB Harmony modules, including application(s). */
    SYS_Initialize ( NULL );


    while ( true )
    {
        /* Maintain state machines of all polled MPLAB Harmony modules. */
        SYS_Tasks ( );

    }

    /* Execution should not come here during normal operation */

    return ( EXIT_FAILURE );
}


/*******************************************************************************
 End of File
*/


//以下、app.c
//-----------------------------------------------------------------------------------
/*******************************************************************************
  MPLAB Harmony Application Source File
  
  Company:
    Microchip Technology Inc.
  
  File Name:
    app.c

  Summary:
    This file contains the source code for the MPLAB Harmony application.

  Description:
    This file contains the source code for the MPLAB Harmony application.  It 
    implements the logic of the application's state machine and it may call 
    API routines of other MPLAB Harmony modules in the system, such as drivers,
    system services, and middleware.  However, it does not call any of the
    system interfaces (such as the "Initialize" and "Tasks" functions) of any of
    the modules in the system or make any assumptions about when those functions
    are called.  That is the responsibility of the configuration-specific system
    files.
 *******************************************************************************/

// DOM-IGNORE-BEGIN
/*******************************************************************************
Copyright (c) 2013-2014 released Microchip Technology Inc.  All rights reserved.

Microchip licenses to you the right to use, modify, copy and distribute
Software only when embedded on a Microchip microcontroller or digital signal
controller that is integrated into your product or third party product
(pursuant to the sublicense terms in the accompanying license agreement).

You should refer to the license agreement accompanying this Software for
additional information regarding your rights and obligations.

SOFTWARE AND DOCUMENTATION ARE PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND,
EITHER EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION, ANY WARRANTY OF
MERCHANTABILITY, TITLE, NON-INFRINGEMENT AND FITNESS FOR A PARTICULAR PURPOSE.
IN NO EVENT SHALL MICROCHIP OR ITS LICENSORS BE LIABLE OR OBLIGATED UNDER
CONTRACT, NEGLIGENCE, STRICT LIABILITY, CONTRIBUTION, BREACH OF WARRANTY, OR
OTHER LEGAL EQUITABLE THEORY ANY DIRECT OR INDIRECT DAMAGES OR EXPENSES
INCLUDING BUT NOT LIMITED TO ANY INCIDENTAL, SPECIAL, INDIRECT, PUNITIVE OR
CONSEQUENTIAL DAMAGES, LOST PROFITS OR LOST DATA, COST OF PROCUREMENT OF
SUBSTITUTE GOODS, TECHNOLOGY, SERVICES, OR ANY CLAIMS BY THIRD PARTIES
(INCLUDING BUT NOT LIMITED TO ANY DEFENSE THEREOF), OR OTHER SIMILAR COSTS.
 *******************************************************************************/
// DOM-IGNORE-END


// *****************************************************************************
// *****************************************************************************
// Section: Included Files 
// *****************************************************************************
// *****************************************************************************

#include "app.h"
#include "1lcd_lib_C32.h"


int delay_Clock = 200000000;   //200MHz

void delay_us(volatile unsigned int usec)        //1μsec遅延
{
        volatile  int count;

        count = (int)(delay_Clock/20000000)*usec;


        do      //実測 at 200MH (Clock=200000000)
        {       //delay_us(1000):1000.4μsec  delay_us(100):100.6μsec  delay_us(10):10.5μsec  delay_us(1):1.5μsec
                asm("NOP"); asm("NOP"); asm("NOP"); asm("NOP"); asm("NOP");asm("NOP");
                asm("NOP"); asm("NOP"); asm("NOP"); asm("NOP"); asm("NOP"); asm("NOP");

                count--;
        }while(count != 0);


}

void delay_ms(volatile unsigned int msec)        //1msec遅延
{
        volatile unsigned int i;         //実測:at200MH (Clock=200000000)//delay_ms(1): 1.0006msec   delay_ms(100):100.04msec

        for(i=0; i<msec; i++)
        delay_us(1000);
}




// *****************************************************************************
// *****************************************************************************
// Section: Global Data Definitions
// *****************************************************************************
// *****************************************************************************

// *****************************************************************************
/* Application Data

  Summary:
    Holds application data

  Description:
    This structure holds the application's data.

  Remarks:
    This structure should be initialized by the APP_Initialize function.
    
    Application strings and buffers are be defined outside this structure.
*/

APP_DATA appData;





// *****************************************************************************
// *****************************************************************************
// Section: MACROS
// *****************************************************************************
// *****************************************************************************
#define MIN(x,y)                ((x > y)? y: x)
#define APP_SCREEN_DELAY_MS         (1000)
// *****************************************************************************
// *****************************************************************************
// Section: Global Variable Definitions
// *****************************************************************************
// *****************************************************************************

// *****************************************************************************
// *****************************************************************************
// Section: Application Local Routines
// *****************************************************************************
void APP_TMR_DelayMS ( unsigned int delayMs );


// *****************************************************************************
// *****************************************************************************
// Section: Application Callback Functions
// *****************************************************************************
// *****************************************************************************

/* TODO:  Add any necessary callback funtions.
*/

// *****************************************************************************
// *****************************************************************************
// Section: Application Local Functions
// *****************************************************************************
// *****************************************************************************

/* TODO:  Add any necessary local functions.
*/


// *****************************************************************************
// *****************************************************************************
// Section: Application Initialization and State Machine Functions
// *****************************************************************************
// *****************************************************************************

/*******************************************************************************
  Function:
    void APP_Initialize ( void )

  Remarks:
    See prototype in app.h.
 */

void APP_Initialize ( void )
{
    /* Place the App state machine in its initial state. */
    appData.state = APP_STATE_INIT;
    
    /* TODO: Initialize your application's state machine and other
     * parameters.
     */
}


/******************************************************************************
  Function:
    void APP_Tasks ( void )

  Remarks:
    See prototype in app.h.
 */

void APP_Tasks ( void )
{
    /* Check the application's current state. */
    switch ( appData.state )
    {
        /* Application's initial state. */
        case APP_STATE_INIT:
        {
            appData.state = APP_HGC_SCREEN1_DRAW;
            break;
        }
        
        case APP_HGC_SCREEN1_DRAW:
        {
            if(hgcObj.screenState != HGC_SCREEN_STATE_DISPLAY_SCREEN_screen1)
                return;
            
            GFX_HGC_ChangeScreen(screen2);
            APP_TMR_DelayMS(1000);
            appData.state = APP_HGC_SCREEN2_DRAW;
            break;
        }    

        case APP_HGC_SCREEN2_DRAW:
        {
            if(hgcObj.screenState != HGC_SCREEN_STATE_DISPLAY_SCREEN_screen2)
                return;
            
            GFX_HGC_ChangeScreen(screen3);
            APP_TMR_DelayMS(1000);
            appData.state = APP_HGC_SCREEN3_DRAW;
            break;
        }
        
        case APP_HGC_SCREEN3_DRAW:
        {
            if(hgcObj.screenState != HGC_SCREEN_STATE_DISPLAY_SCREEN_screen3)
                return;
            
            GFX_HGC_ChangeScreen(screen1);
            APP_TMR_DelayMS(1000);
            appData.state = APP_HGC_SCREEN1_DRAW;
            break;
        }    

        /* The default state should never be executed. */
        default:
        {
            /* TODO: Handle error in application's state machine. */
            break;
        }
    }
}

void APP_TMR_DelayMS ( unsigned int delayMs )
{
    if(delayMs)
    {
        uint32_t sysClk = SYS_CLK_FREQ;
        uint32_t t0;
        t0 = _CP0_GET_COUNT();
        while (_CP0_GET_COUNT() - t0 < (sysClk/2000)*delayMs);
    }
}

/*******************************************************************************
 End of File
 */





//以下、app.h
//-----------------------------------------------------------------------------------
/*******************************************************************************
  MPLAB Harmony Application Header File

  Company:
    Microchip Technology Inc.

  File Name:
    app.h

  Summary:
    This header file provides prototypes and definitions for the application.

  Description:
    This header file provides function prototypes and data type definitions for
    the application.  Some of these are required by the system (such as the
    "APP_Initialize" and "APP_Tasks" prototypes) and some of them are only used
    internally by the application (such as the "APP_STATES" definition).  Both
    are defined here for convenience.
*******************************************************************************/

//DOM-IGNORE-BEGIN
/*******************************************************************************
Copyright (c) 2013-2014 released Microchip Technology Inc.  All rights reserved.

Microchip licenses to you the right to use, modify, copy and distribute
Software only when embedded on a Microchip microcontroller or digital signal
controller that is integrated into your product or third party product
(pursuant to the sublicense terms in the accompanying license agreement).

You should refer to the license agreement accompanying this Software for
additional information regarding your rights and obligations.

SOFTWARE AND DOCUMENTATION ARE PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND,
EITHER EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION, ANY WARRANTY OF
MERCHANTABILITY, TITLE, NON-INFRINGEMENT AND FITNESS FOR A PARTICULAR PURPOSE.
IN NO EVENT SHALL MICROCHIP OR ITS LICENSORS BE LIABLE OR OBLIGATED UNDER
CONTRACT, NEGLIGENCE, STRICT LIABILITY, CONTRIBUTION, BREACH OF WARRANTY, OR
OTHER LEGAL EQUITABLE THEORY ANY DIRECT OR INDIRECT DAMAGES OR EXPENSES
INCLUDING BUT NOT LIMITED TO ANY INCIDENTAL, SPECIAL, INDIRECT, PUNITIVE OR
CONSEQUENTIAL DAMAGES, LOST PROFITS OR LOST DATA, COST OF PROCUREMENT OF
SUBSTITUTE GOODS, TECHNOLOGY, SERVICES, OR ANY CLAIMS BY THIRD PARTIES
(INCLUDING BUT NOT LIMITED TO ANY DEFENSE THEREOF), OR OTHER SIMILAR COSTS.
 *******************************************************************************/
//DOM-IGNORE-END

#ifndef _APP_H
#define _APP_H

// *****************************************************************************
// *****************************************************************************
// Section: Included Files
// *****************************************************************************
// *****************************************************************************

#include <stdint.h>
#include <stdbool.h>
#include <stddef.h>
#include <stdlib.h>
#include "system_config.h"
#include "system_definitions.h"

// *****************************************************************************
// *****************************************************************************
// Section: Type Definitions
// *****************************************************************************
// *****************************************************************************

// *****************************************************************************
/* Application states

  Summary:
    Application states enumeration

  Description:
    This enumeration defines the valid application states.  These states
    determine the behavior of the application at various times.
*/

typedef enum
{
       /* Application pixels put*/
    APP_STATE_INIT=0,

    /* Application primitive draw */
    //APP_PRIMITIVE_DRAW,
            
    APP_HGC_SCREEN1_DRAW,
            
    APP_HGC_SCREEN2_DRAW,
            
    APP_HGC_SCREEN3_DRAW,

    /* Application done */
    APP_STATE_DONE,

} APP_STATES;


// *****************************************************************************
/* Application Data

  Summary:
    Holds application data

  Description:
    This structure holds the application's data.

  Remarks:
    Application strings and buffers are be defined outside this structure.
 */

typedef struct
{
 
    /* Application's current state*/
    APP_STATES state;

    GFX_HANDLE gfxHandle[GFX_INSTANCES_NUMBER];


} APP_DATA;


// *****************************************************************************
// *****************************************************************************
// Section: Application Callback Routines
// *****************************************************************************
// *****************************************************************************
/* These routines are called by drivers when certain events occur.
*/

        
// *****************************************************************************
// *****************************************************************************
// Section: Application Initialization and State Machine Functions
// *****************************************************************************
// *****************************************************************************

/*******************************************************************************
  Function:
    void APP_Initialize ( void )

  Summary:
     MPLAB Harmony application initialization routine.

  Description:
    This function initializes the Harmony application.  It places the 
    application in its initial state and prepares it to run so that its 
    APP_Tasks function can be called.

  Precondition:
    All other system initialization routines should be called before calling
    this routine (in "SYS_Initialize").

  Parameters:
    None.

  Returns:
    None.

  Example:
    <code>
    APP_Initialize();
    </code>

  Remarks:
    This routine must be called from the SYS_Initialize function.
*/

void APP_Initialize ( void );


/*******************************************************************************
  Function:
    void APP_Tasks ( void )

  Summary:
    MPLAB Harmony Demo application tasks function

  Description:
    This routine is the Harmony Demo application's tasks function.  It
    defines the application's state machine and core logic.

  Precondition:
    The system and application initialization ("SYS_Initialize") should be
    called before calling this.

  Parameters:
    None.

  Returns:
    None.

  Example:
    <code>
    APP_Tasks();
    </code>

  Remarks:
    This routine must be called from SYS_Tasks() routine.
 */

void APP_Tasks( void );


#endif /* _APP_H */
/*******************************************************************************
 End of File
 */





//以下、gfx_hgc_definitions.c
//-------------------------------------------------------------------------------------------------
/*******************************************************************************
  MPLAB Harmony Graphics Composer Generated Implementation File

  File Name:
    gfx_hgc_definitions.c

  Summary:
    Build-time generated implementation from the MPLAB Harmony
    Graphics Composer.

  Description:
    Build-time generated implementation from the MPLAB Harmony
    Graphics Composer.

    Created with MPLAB Harmony Version 1.05
*******************************************************************************/
// DOM-IGNORE-BEGIN
/*******************************************************************************
Copyright (c) 2013-2014 released Microchip Technology Inc.  All rights reserved.

Microchip licenses to you the right to use, modify, copy and distribute
Software only when embedded on a Microchip microcontroller or digital signal
controller that is integrated into your product or third party product
(pursuant to the sublicense terms in the accompanying license agreement).

You should refer to the license agreement accompanying this Software for
additional information regarding your rights and obligations.

SOFTWARE AND DOCUMENTATION ARE PROVIDED AS IS WITHOUT WARRANTY OF ANY KIND,
EITHER EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION, ANY WARRANTY OF
MERCHANTABILITY, TITLE, NON-INFRINGEMENT AND FITNESS FOR A PARTICULAR PURPOSE.
IN NO EVENT SHALL MICROCHIP OR ITS LICENSORS BE LIABLE OR OBLIGATED UNDER
CONTRACT, NEGLIGENCE, STRICT LIABILITY, CONTRIBUTION, BREACH OF WARRANTY, OR
OTHER LEGAL EQUITABLE THEORY ANY DIRECT OR INDIRECT DAMAGES OR EXPENSES
INCLUDING BUT NOT LIMITED TO ANY INCIDENTAL, SPECIAL, INDIRECT, PUNITIVE OR
CONSEQUENTIAL DAMAGES, LOST PROFITS OR LOST DATA, COST OF PROCUREMENT OF
SUBSTITUTE GOODS, TECHNOLOGY, SERVICES, OR ANY CLAIMS BY THIRD PARTIES
(INCLUDING BUT NOT LIMITED TO ANY DEFENSE THEREOF), OR OTHER SIMILAR COSTS.
*******************************************************************************/
// DOM-IGNORE-END

#include "gfx_hgc_definitions.h"

/*** Default GFX GOL Scheme ***/
#define GFX_SCHEMEDEFAULT GOLSchemeDefault
extern GFX_GOL_OBJ_SCHEME GFX_SCHEMEDEFAULT;

/*** HGC-specified GFX GOL Scheme ***/
static GFX_GOL_OBJ_SCHEME *gfxScheme0;

/*** Generated Asset References ***/
extern const GFX_RESOURCE_HDR flower16bit;
extern const GFX_RESOURCE_HDR fireflysung;

/*** Generated ASCII Text Labels ***/
static const GFX_XCHAR staticTextStr_0[] = { 0x31, 0x36, 0x62, 0x69, 0x74, 0x20, 0x42, 0x50, 0x50, 0x0 }; // 16bit BPP
/*** HGC Object Global ***/
HGC_OBJECTS hgcObj;
static HGC_STATES hgcState;

/******************************************************************************
  Function:
    HGC_SCREEN_STATES GFX_HGC_GetScreenState ( void )

  Remarks:
    This function returns the screen state
 */
HGC_SCREEN_STATES GFX_HGC_GetScreenState ( void )
{
    return hgcObj.screenState;
}


/******************************************************************************
  Function:
    void GFX_HGC_SetScreenState ( HGC_SCREEN_STATES newState )

  Remarks:
    This function sets the screen state machine to a new state
 */
void GFX_HGC_SetScreenState ( HGC_SCREEN_STATES newState )
{
    hgcObj.prevRefreshState = hgcObj.screenState;
    hgcObj.screenState = newState;
}


/******************************************************************************
  Function:
    void GFX_HGC_Setup ( void )

  Summary:
    This function sets up the GOL message callback and draw callbacks.  
 */
void GFX_HGC_Setup ( void )
{
    GFX_GOL_MessageCallbackSet(GFX_INDEX_0, &GFX_HGC_MessageCallback);
    GFX_GOL_DrawCallbackSet(GFX_INDEX_0, &GFX_HGC_DrawCallback);

    GFX_HGC_InitializeSchemes();

}

/******************************************************************************
  Function:
    void GFX_HGC_Tasks (SYS_MODULE_OBJ gfxObject);

  Summary:
    This function is called in SYS_Tasks.  The intent wait until the GFX library
    is initialized before supplying items to draw
*/
void GFX_HGC_Tasks  (SYS_MODULE_OBJ gfxObject)
{
    switch ( hgcState )
    {
        case HGC_STATE_INIT:
            if (GFX_Status(gfxObject)==SYS_STATUS_READY)
            {
                GFX_HGC_Setup();
                hgcState = HGC_STATE_RUNNING;
            }
            break;

        case HGC_STATE_RUNNING:
            break;

        default:
            break;
    }
}

/******************************************************************************
  Function:
    void GFX_HGC_SchemeCreate ( void )

  Summary:
    Allocates memory for a new scheme
 */
GFX_GOL_OBJ_SCHEME *GFX_HGC_SchemeCreate(void)
{
    GFX_GOL_OBJ_SCHEME  *pTemp;

    pTemp = (GFX_GOL_OBJ_SCHEME *)GFX_malloc(sizeof(GFX_GOL_OBJ_SCHEME));

    if(pTemp != NULL)
    {
        memcpy(pTemp, &GFX_SCHEMEDEFAULT, sizeof(GFX_GOL_OBJ_SCHEME));
    }

    return (pTemp);
}

/******************************************************************************
  Function:
    void GFX_HGC_InitializeSchemes ( void )

  Summary:
    Initializes all HGC-specified schemes
 */
void GFX_HGC_InitializeSchemes( void )
{
    gfxScheme0 = GFX_HGC_SchemeCreate();

#ifndef GFX_CONFIG_ALPHABLEND_DISABLE
    gfxScheme0->AlphaValue =        GFX_SCHEME_ALPHA_0;
#endif
    gfxScheme0->Color0 =            GFX_RGBConvert(GFX_SCHEME_PRIMARY_COLOR_RED_0, GFX_SCHEME_PRIMARY_COLOR_GREEN_0, GFX_SCHEME_PRIMARY_COLOR_BLUE_0);
    gfxScheme0->Color1 =            GFX_RGBConvert(GFX_SCHEME_SECONDARY_COLOR_RED_0, GFX_SCHEME_SECONDARY_COLOR_GREEN_0, GFX_SCHEME_SECONDARY_COLOR_BLUE_0);
    gfxScheme0->ColorDisabled =     GFX_RGBConvert(GFX_SCHEME_DISABLED_COLOR_RED_0, GFX_SCHEME_DISABLED_COLOR_GREEN_0, GFX_SCHEME_DISABLED_COLOR_BLUE_0);
    gfxScheme0->CommonBkColor =     GFX_RGBConvert(GFX_SCHEME_BACKGROUND_COLOR_RED_0, GFX_SCHEME_BACKGROUND_COLOR_GREEN_0, GFX_SCHEME_BACKGROUND_COLOR_BLUE_0);
        gfxScheme0->EmbossSize =        GFX_SCHEME_EMBOSS_SIZE_0;
    gfxScheme0->EmbossDkColor =     GFX_RGBConvert(GFX_SCHEME_EMBOSS_DARK_COLOR_RED_0, GFX_SCHEME_EMBOSS_DARK_COLOR_GREEN_0, GFX_SCHEME_EMBOSS_DARK_COLOR_BLUE_0);
    gfxScheme0->EmbossLtColor =     GFX_RGBConvert(GFX_SCHEME_EMBOSS_LIGHT_COLOR_RED_0, GFX_SCHEME_EMBOSS_LIGHT_COLOR_GREEN_0, GFX_SCHEME_EMBOSS_LIGHT_COLOR_BLUE_0);
        gfxScheme0->TextColor0 =        GFX_RGBConvert(GFX_SCHEME_TEXT_PRIMARY_COLOR_RED_0, GFX_SCHEME_TEXT_PRIMARY_COLOR_GREEN_0, GFX_SCHEME_TEXT_PRIMARY_COLOR_BLUE_0);
    gfxScheme0->TextColor1 =        GFX_RGBConvert(GFX_SCHEME_TEXT_SECONDARY_COLOR_RED_0, GFX_SCHEME_TEXT_SECONDARY_COLOR_GREEN_0, GFX_SCHEME_TEXT_SECONDARY_COLOR_BLUE_0);
    gfxScheme0->TextColorDisabled = GFX_RGBConvert(GFX_SCHEME_TEXT_DISABLED_COLOR_RED_0, GFX_SCHEME_TEXT_DISABLED_COLOR_GREEN_0, GFX_SCHEME_TEXT_DISABLED_COLOR_BLUE_0);
#ifndef GFX_CONFIG_GRADIENT_DISABLE
        gfxScheme0->gradientStartColor = GFX_RGBConvert(GFX_SCHEME_GRADIENT_START_COLOR_RED_0, GFX_SCHEME_GRADIENT_START_COLOR_GREEN_0, GFX_SCHEME_GRADIENT_START_COLOR_BLUE_0);
        gfxScheme0->gradientEndColor = GFX_RGBConvert(GFX_SCHEME_GRADIENT_END_COLOR_RED_0, GFX_SCHEME_GRADIENT_END_COLOR_GREEN_0, GFX_SCHEME_GRADIENT_END_COLOR_BLUE_0);
#endif
    gfxScheme0->CommonBkLeft =      GFX_SCHEME_BACKGROUND_OFFSET_TOP_0;
    gfxScheme0->CommonBkTop =       GFX_SCHEME_BACKGROUND_OFFSET_LEFT_0;
    gfxScheme0->pFont =             (GFX_RESOURCE_HDR*)&fireflysung;
    gfxScheme0->pCommonBkImage =    (GFX_RESOURCE_HDR*)NULL;
        
        gfxScheme0->fillStyle =         GFX_SCHEME_FILL_STYLE_0;
        gfxScheme0->CommonBkType =      GFX_SCHEME_BACKGROUND_TYPE_0;

}

/******************************************************************************
  Function: 
    bool GFX_HGC_MESSAGECallback(uint16_t objMsg, GFX_GOL_OBJ_HEADER* pObj, GFX_GOL_MESSAGE* pMsg)

  Input: 
    objMsg - translated message for the object,
    pObj - pointer to the object,
    pMsg - pointer to the non-translated, raw GOL message

  Output: 
    If the function returns non-zero the message will be processed by default

  Remarks: 
    GFX_GOL_MESSAGECallback() function calls it each time the valid message for the GOL object is received.
 */
bool GFX_HGC_MessageCallback(GFX_GOL_TRANSLATED_ACTION objMsg, GFX_GOL_OBJ_HEADER *pObj, GFX_GOL_MESSAGE *pMsg)
{
    // process messages for demo screens
    switch (hgcObj.screenState)
    {
        case HGC_SCREEN_STATE_DISPLAY_SCREEN_screen1:
            if (GFX_HGC_MsgPictures(objMsg, pObj) == true)
                return true;
            if (GFX_HGC_MsgStaticTexts(objMsg, pObj) == true)
                return true;
            break;
        case HGC_SCREEN_STATE_DISPLAY_SCREEN_screen2:
            if (GFX_HGC_MsgPictures(objMsg, pObj) == true)
                return true;
            if (GFX_HGC_MsgStaticTexts(objMsg, pObj) == true)
                return true;
            break;
        case HGC_SCREEN_STATE_DISPLAY_SCREEN_screen3:
            if (GFX_HGC_MsgPictures(objMsg, pObj) == true)
                return true;
            if (GFX_HGC_MsgStaticTexts(objMsg, pObj) == true)
                return true;
            break;
      default:
            // process message by default
            return true;
    }
    return true;
}

/******************************************************************************
  Function: 
    bool GFX_HGC_DrawCallback( void )

  Output: 
    If the function returns non-zero the draw control will be passed to GOL

  Remarks: 
    GFX_GOL_Draw() function calls it each time when GOL objects drawing is 
    completed. HGC-specified draw data is grouped by screens states. It takes 
    two states to complete the drawing of each screen.  GFX GOL objects are drawn
    first and then GFX Primitives are drawn next to ensure primitives are not
    covered by GOL objects.
 */
bool GFX_HGC_DrawCallback( void )
{
    switch (hgcObj.screenState)
    {
        case HGC_SCREEN_STATE_INIT:
            //Draw the primary screen as selected in the Composer
            GFX_HGC_SetScreenState(HGC_SCREEN_STATE_SETUP_SCREEN_screen1);
            return true;
        case HGC_SCREEN_STATE_SETUP_SCREEN_screen1:
            GFX_HGC_SetScreenState(HGC_SCREEN_STATE_PRE_DRAW_GOL_SCREEN_screen1);
            break;
        case HGC_SCREEN_STATE_PRE_DRAW_GOL_SCREEN_screen1:
            GFX_HGC_SetScreenState(HGC_SCREEN_STATE_DRAW_GOL_SCREEN_screen1);
            break;
        case HGC_SCREEN_STATE_DRAW_GOL_SCREEN_screen1:
            GFX_HGC_SetupScreen(screen1);
            GFX_HGC_DrawScreen_GOL(screen1);
            GFX_HGC_SetScreenState(HGC_SCREEN_STATE_POST_DRAW_GOL_SCREEN_screen1);
            break;
        case HGC_SCREEN_STATE_POST_DRAW_GOL_SCREEN_screen1:
            GFX_HGC_SetScreenState(HGC_SCREEN_STATE_PRE_DRAW_PRIMITIVE_SCREEN_screen1);
            break;
        case HGC_SCREEN_STATE_PRE_DRAW_PRIMITIVE_SCREEN_screen1:
            GFX_HGC_SetScreenState(HGC_SCREEN_STATE_DRAW_PRIMITIVE_SCREEN_screen1);
            break;
        case HGC_SCREEN_STATE_DRAW_PRIMITIVE_SCREEN_screen1:
            GFX_HGC_DrawScreen_Primitives(screen1);
            GFX_HGC_SetScreenState(HGC_SCREEN_STATE_POST_DRAW_PRIMITIVE_SCREEN_screen1);
            break;
        case HGC_SCREEN_STATE_POST_DRAW_PRIMITIVE_SCREEN_screen1:
            GFX_HGC_SetScreenState(HGC_SCREEN_STATE_DISPLAY_SCREEN_screen1);
            break;
        case HGC_SCREEN_STATE_DISPLAY_SCREEN_screen1:
            break;
        case HGC_SCREEN_STATE_SETUP_SCREEN_screen2:
            GFX_HGC_SetScreenState(HGC_SCREEN_STATE_PRE_DRAW_GOL_SCREEN_screen2);
            break;
        case HGC_SCREEN_STATE_PRE_DRAW_GOL_SCREEN_screen2:
            GFX_HGC_SetScreenState(HGC_SCREEN_STATE_DRAW_GOL_SCREEN_screen2);
            break;
        case HGC_SCREEN_STATE_DRAW_GOL_SCREEN_screen2:
            GFX_HGC_SetupScreen(screen2);
            GFX_HGC_DrawScreen_GOL(screen2);
            GFX_HGC_SetScreenState(HGC_SCREEN_STATE_POST_DRAW_GOL_SCREEN_screen2);
            break;
        case HGC_SCREEN_STATE_POST_DRAW_GOL_SCREEN_screen2:
            GFX_HGC_SetScreenState(HGC_SCREEN_STATE_PRE_DRAW_PRIMITIVE_SCREEN_screen2);
            break;
        case HGC_SCREEN_STATE_PRE_DRAW_PRIMITIVE_SCREEN_screen2:
            GFX_HGC_SetScreenState(HGC_SCREEN_STATE_DRAW_PRIMITIVE_SCREEN_screen2);
            break;
        case HGC_SCREEN_STATE_DRAW_PRIMITIVE_SCREEN_screen2:
            GFX_HGC_DrawScreen_Primitives(screen2);
            GFX_HGC_SetScreenState(HGC_SCREEN_STATE_POST_DRAW_PRIMITIVE_SCREEN_screen2);
            break;
        case HGC_SCREEN_STATE_POST_DRAW_PRIMITIVE_SCREEN_screen2:
            GFX_HGC_SetScreenState(HGC_SCREEN_STATE_DISPLAY_SCREEN_screen2);
            break;
        case HGC_SCREEN_STATE_DISPLAY_SCREEN_screen2:
            break;
        case HGC_SCREEN_STATE_SETUP_SCREEN_screen3:
            GFX_HGC_SetScreenState(HGC_SCREEN_STATE_PRE_DRAW_GOL_SCREEN_screen3);
            break;
        case HGC_SCREEN_STATE_PRE_DRAW_GOL_SCREEN_screen3:
            GFX_HGC_SetScreenState(HGC_SCREEN_STATE_DRAW_GOL_SCREEN_screen3);
            break;
        case HGC_SCREEN_STATE_DRAW_GOL_SCREEN_screen3:
            GFX_HGC_SetupScreen(screen3);
            GFX_HGC_DrawScreen_GOL(screen3);
            GFX_HGC_SetScreenState(HGC_SCREEN_STATE_POST_DRAW_GOL_SCREEN_screen3);
            break;
        case HGC_SCREEN_STATE_POST_DRAW_GOL_SCREEN_screen3:
            GFX_HGC_SetScreenState(HGC_SCREEN_STATE_PRE_DRAW_PRIMITIVE_SCREEN_screen3);
            break;
        case HGC_SCREEN_STATE_PRE_DRAW_PRIMITIVE_SCREEN_screen3:
            GFX_HGC_SetScreenState(HGC_SCREEN_STATE_DRAW_PRIMITIVE_SCREEN_screen3);
            break;
        case HGC_SCREEN_STATE_DRAW_PRIMITIVE_SCREEN_screen3:
            GFX_HGC_DrawScreen_Primitives(screen3);
            GFX_HGC_SetScreenState(HGC_SCREEN_STATE_POST_DRAW_PRIMITIVE_SCREEN_screen3);
            break;
        case HGC_SCREEN_STATE_POST_DRAW_PRIMITIVE_SCREEN_screen3:
            GFX_HGC_SetScreenState(HGC_SCREEN_STATE_DISPLAY_SCREEN_screen3);
            break;
        case HGC_SCREEN_STATE_DISPLAY_SCREEN_screen3:
            break;
        default:
            return true; // release drawing control to GOL by default
    }

    return true; // release drawing control to GOL
}

/******************************************************************************
  Function: 
    void GFX_HGC_SetupScreen( uint8_t  screenId )

  Remarks: 
    Clears current screen and starts a fresh screen with its background color
 */
void GFX_HGC_SetupScreen(uint8_t screenId)
{
    switch (screenId)
    {
        case screen1:
            GFX_ColorSet(GFX_INDEX_0, GFX_RGBConvert(0x00, 0x00, 0x00));
            GFX_ScreenClear(GFX_INDEX_0);

            GFX_GOL_ObjectListFree(GFX_INDEX_0); // free memory for the objects in the previous linked list and start new list
            break;
        case screen2:
            GFX_ColorSet(GFX_INDEX_0, GFX_RGBConvert(0x00, 0x00, 0x00));
            GFX_ScreenClear(GFX_INDEX_0);

            GFX_GOL_ObjectListFree(GFX_INDEX_0); // free memory for the objects in the previous linked list and start new list
            break;
        case screen3:
            GFX_ColorSet(GFX_INDEX_0, GFX_RGBConvert(0x00, 0x00, 0x00));
            GFX_ScreenClear(GFX_INDEX_0);

            GFX_GOL_ObjectListFree(GFX_INDEX_0); // free memory for the objects in the previous linked list and start new list
            break;
        default:
            break;
    }
}


/******************************************************************************
  Function: 
    bool GFX_HGC_ChangeScreen( uint8_t  screenId )

  Output: 
    Returns true if a screenId matches an existing screen identifier

  Remarks: 
    Can be called to initiate GFX Library to draw a new screen
 */
bool GFX_HGC_ChangeScreen(uint8_t screenId)
{
    switch (screenId)
    {
        case screen1:
            GFX_HGC_SetScreenState(HGC_SCREEN_STATE_SETUP_SCREEN_screen1);
            break;
        case screen2:
            GFX_HGC_SetScreenState(HGC_SCREEN_STATE_SETUP_SCREEN_screen2);
            break;
        case screen3:
            GFX_HGC_SetScreenState(HGC_SCREEN_STATE_SETUP_SCREEN_screen3);
            break;
        default:
            return false;
    }

    return true; // release drawing control to GOL
}

/******************************************************************************
  Function: 
    bool GFX_HGC_DrawScreen_GOL( uint8_t  screenId )

  Output: 
    Returns true if a screenId matches an existing screen identifier

  Remarks: 
    HGC-specified GFX GOL objects are drawn here, grouped by screen.
    The draw order is reverse Z-ordered.
 */
bool GFX_HGC_DrawScreen_GOL(uint8_t screenId)
{
    switch (screenId)
    {
        case screen1:
            break;
        case screen2:
            GFX_HGC_DrawItem(Picture1);
            GFX_HGC_DrawItem(StaticText1);
            break;
        case screen3:
            break;
        default:
            return false;
    }

    return true; // release drawing control to GOL
}


/******************************************************************************
  Function: 
    bool GFX_HGC_DrawScreen_Primitives( uint8_t  screenId )

  Output:
    Returns true if a screenId matches an existing screen identifier

  Remarks: 
    HGC-specified GFX Primitives are drawn here, grouped by screen.
    GFX Primitives are drawn after GFX GOL Objects to make sure GFX GOL Objects
    do not cover GFX Primitives
 */
bool GFX_HGC_DrawScreen_Primitives(uint8_t screenId)
{
    switch (screenId)
    {
        case screen1:
            GFX_HGC_DrawItem(Circle1);
            GFX_HGC_DrawItem(Circle2);
            GFX_HGC_DrawItem(Circle3);
            GFX_HGC_DrawItem(Circle4);
            GFX_HGC_DrawItem(Circle5);
            GFX_HGC_DrawItem(Circle6);
            GFX_HGC_DrawItem(Circle7);
            GFX_HGC_DrawItem(Circle8);
            GFX_HGC_DrawItem(Circle9);
            GFX_HGC_DrawItem(Circle10);
            GFX_HGC_DrawItem(Line1);
            GFX_HGC_DrawItem(Line2);
            GFX_HGC_DrawItem(Line3);
            GFX_HGC_DrawItem(Line4);
            GFX_HGC_DrawItem(Line5);
            GFX_HGC_DrawItem(Line6);
            GFX_HGC_DrawItem(Line7);
            GFX_HGC_DrawItem(Line8);
            GFX_HGC_DrawItem(Line9);
            GFX_HGC_DrawItem(Line10);
            GFX_HGC_DrawItem(Line11);
            break;
        case screen2:
            break;
        case screen3:
            GFX_HGC_DrawItem(Rectangle2);
            GFX_HGC_DrawItem(Rectangle3);
            GFX_HGC_DrawItem(Rectangle1);
            GFX_HGC_DrawItem(Rectangle4);
            GFX_HGC_DrawItem(Rectangle5);
            break;
        default:
            return true;
    }

    return true; // release drawing control to GOL
}


/******************************************************************************
  Function: 
    bool GFX_HGC_DrawItem(int itemId)

  Output:
    Returns true if a itemId matches an existing item identifier

  Remarks: 
    Every item specified in every screen in HGC is listed in this function
 */
bool GFX_HGC_DrawItem(int itemId)
{
    switch(itemId)
    {
    case StaticText1:
        hgcObj.pStaticText1Obj = GFX_GOL_StaticTextCreate
                (
                 GFX_INDEX_0,
                 StaticText1,      // button ID
                 GFX_STATICTEXT_LEFT_0,    // left
                 GFX_STATICTEXT_TOP_0,     // top
                 GFX_STATICTEXT_RIGHT_0,   // right
                 GFX_STATICTEXT_BOTTOM_0,  // bottom
                 GFX_STATICTEXT_STATE_0,   // state
                 (GFX_XCHAR*)staticTextStr_0,    // text
                 GFX_STATICTEXT_ALIGNMENT_0,       //alignment
                 GFX_STATICTEXT_SCHEME_0
                 ); // use alternate scheme
        break;
    case Picture1:
        hgcObj.pPicture1Obj = GFX_GOL_PictureControlCreate
                (
                 GFX_INDEX_0,
                 Picture1,      // picture ID
                 GFX_PICTURE_LEFT_0,    // left
                 GFX_PICTURE_TOP_0,     // top
                 GFX_PICTURE_RIGHT_0,   // right                                 
                 GFX_PICTURE_BOTTOM_0,  // bottom
                                 GFX_PICTURE_STATE_0,   // state                 
                 GFX_PICTURE_SCALE_0,     // scale
                 (GFX_RESOURCE_HDR*)&flower16bit,    // bitmap
                 GFX_PICTURE_SCHEME_0
                 );
        break;
                case Line11:
                {
                        GFX_ColorSet(GFX_INDEX_0, GFX_RGBConvert(0xF8, 0xFC, 0xF8));
                        GFX_LineStyleSet(GFX_INDEX_0, GFX_LINE_STYLE_THIN_SOLID);
                        GFX_LineDraw(GFX_INDEX_0,
                                                 267,  // p1x
                                                 0,  // p1y
                                                 53,  // p2x
                                                 239); // p2y
                        break;
                }               
                case Line10:
                {
                        GFX_ColorSet(GFX_INDEX_0, GFX_RGBConvert(0xF8, 0xFC, 0xF8));
                        GFX_LineStyleSet(GFX_INDEX_0, GFX_LINE_STYLE_THIN_SOLID);
                        GFX_LineDraw(GFX_INDEX_0,
                                                 214,  // p1x
                                                 0,  // p1y
                                                 106,  // p2x
                                                 239); // p2y
                        break;
                }               
                case Line9:
                {
                        GFX_ColorSet(GFX_INDEX_0, GFX_RGBConvert(0xF8, 0xFC, 0xF8));
                        GFX_LineStyleSet(GFX_INDEX_0, GFX_LINE_STYLE_THIN_SOLID);
                        GFX_LineDraw(GFX_INDEX_0,
                                                 106,  // p1x
                                                 0,  // p1y
                                                 214,  // p2x
                                                 239); // p2y
                        break;
                }               
                case Line8:
                {
                        GFX_ColorSet(GFX_INDEX_0, GFX_RGBConvert(0xF8, 0xFC, 0xF8));
                        GFX_LineStyleSet(GFX_INDEX_0, GFX_LINE_STYLE_THIN_SOLID);
                        GFX_LineDraw(GFX_INDEX_0,
                                                 53,  // p1x
                                                 0,  // p1y
                                                 267,  // p2x
                                                 239); // p2y
                        break;
                }               
                case Line7:
                {
                        GFX_ColorSet(GFX_INDEX_0, GFX_RGBConvert(0xF8, 0xFC, 0xF8));
                        GFX_LineStyleSet(GFX_INDEX_0, GFX_LINE_STYLE_THIN_SOLID);
                        GFX_LineDraw(GFX_INDEX_0,
                                                 160,  // p1x
                                                 0,  // p1y
                                                 160,  // p2x
                                                 239); // p2y
                        break;
                }               
                case Line6:
                {
                        GFX_ColorSet(GFX_INDEX_0, GFX_RGBConvert(0xF8, 0xFC, 0xF8));
                        GFX_LineStyleSet(GFX_INDEX_0, GFX_LINE_STYLE_THIN_SOLID);
                        GFX_LineDraw(GFX_INDEX_0,
                                                 0,  // p1x
                                                 239,  // p1y
                                                 319,  // p2x
                                                 0); // p2y
                        break;
                }               
                case Line5:
                {
                        GFX_ColorSet(GFX_INDEX_0, GFX_RGBConvert(0xF8, 0xFC, 0xF8));
                        GFX_LineStyleSet(GFX_INDEX_0, GFX_LINE_STYLE_THIN_SOLID);
                        GFX_LineDraw(GFX_INDEX_0,
                                                 0,  // p1x
                                                 0,  // p1y
                                                 319,  // p2x
                                                 239); // p2y
                        break;
                }               
                case Line4:
                {
                        GFX_ColorSet(GFX_INDEX_0, GFX_RGBConvert(0x00, 0xFC, 0x00));
                        GFX_LineStyleSet(GFX_INDEX_0, GFX_LINE_STYLE_THIN_SOLID);
                        GFX_LineDraw(GFX_INDEX_0,
                                                 319,  // p1x
                                                 0,  // p1y
                                                 319,  // p2x
                                                 239); // p2y
                        break;
                }               
                case Line3:
                {
                        GFX_ColorSet(GFX_INDEX_0, GFX_RGBConvert(0xF8, 0xFC, 0x00));
                        GFX_LineStyleSet(GFX_INDEX_0, GFX_LINE_STYLE_THIN_SOLID);
                        GFX_LineDraw(GFX_INDEX_0,
                                                 0,  // p1x
                                                 0,  // p1y
                                                 0,  // p2x
                                                 239); // p2y
                        break;
                }               
                case Line2:
                {
                        GFX_ColorSet(GFX_INDEX_0, GFX_RGBConvert(0x00, 0x00, 0xF8));
                        GFX_LineStyleSet(GFX_INDEX_0, GFX_LINE_STYLE_THIN_SOLID);
                        GFX_LineDraw(GFX_INDEX_0,
                                                 0,  // p1x
                                                 239,  // p1y
                                                 319,  // p2x
                                                 239); // p2y
                        break;
                }               
                case Line1:
                {
                        GFX_ColorSet(GFX_INDEX_0, GFX_RGBConvert(0xF8, 0x00, 0x00));
                        GFX_LineStyleSet(GFX_INDEX_0, GFX_LINE_STYLE_THIN_SOLID);
                        GFX_LineDraw(GFX_INDEX_0,
                                                 0,  // p1x
                                                 0,  // p1y
                                                 319,  // p2x
                                                 0); // p2y
                        break;
                }               
                case Rectangle5:
                {
                        GFX_ColorSet(GFX_INDEX_0, GFX_RGBConvert(0x00, 0x00, 0xF8));
                        GFX_LineStyleSet(GFX_INDEX_0, GFX_LINE_STYLE_THIN_SOLID);
                        GFX_RectangleDraw(GFX_INDEX_0,
                                                          65,  // p1x
                                                          30,  // p1y
                                                          255,  // p2x
                                                          210); // p2y
                        
                        break;
                }       
                case Rectangle4:
                {
                        GFX_ColorSet(GFX_INDEX_0, GFX_RGBConvert(0x00, 0x00, 0xF8));
                        GFX_LineStyleSet(GFX_INDEX_0, GFX_LINE_STYLE_THIN_SOLID);
                        GFX_RectangleDraw(GFX_INDEX_0,
                                                          80,  // p1x
                                                          45,  // p1y
                                                          240,  // p2x
                                                          195); // p2y
                        
                        break;
                }       
                case Rectangle1:
                {
                        GFX_FillStyleSet(GFX_INDEX_0, GFX_FILL_STYLE_ALPHA_COLOR);
                        GFX_ColorSet(GFX_INDEX_0, GFX_RGBConvert(0xF8, 0x00, 0x00));
                        GFX_AlphaBlendingValueSet(GFX_INDEX_0, 100);
                        GFX_RectangleFillDraw(GFX_INDEX_0,
                                                                  125,  // p1x
                                                                  90,  // p1y
                                                                  195,  // p2x
                                                                  150); // p2y
                        
                        GFX_ColorSet(GFX_INDEX_0, GFX_RGBConvert(0xF8, 0x00, 0x00));
                        GFX_LineStyleSet(GFX_INDEX_0, GFX_LINE_STYLE_THIN_SOLID);
                        GFX_RectangleDraw(GFX_INDEX_0,
                                                          125,  // p1x
                                                          90,  // p1y
                                                          195,  // p2x
                                                          150); // p2y
                        
                        break;
                }       
                case Rectangle3:
                {
                        GFX_FillStyleSet(GFX_INDEX_0, GFX_FILL_STYLE_COLOR);
                        GFX_ColorSet(GFX_INDEX_0, GFX_RGBConvert(0x00, 0xFC, 0x00));
                        GFX_RectangleFillDraw(GFX_INDEX_0,
                                                                  110,  // p1x
                                                                  75,  // p1y
                                                                  210,  // p2x
                                                                  165); // p2y
                        
                        GFX_ColorSet(GFX_INDEX_0, GFX_RGBConvert(0x00, 0xFC, 0x00));
                        GFX_LineStyleSet(GFX_INDEX_0, GFX_LINE_STYLE_THIN_SOLID);
                        GFX_RectangleDraw(GFX_INDEX_0,
                                                          110,  // p1x
                                                          75,  // p1y
                                                          210,  // p2x
                                                          165); // p2y
                        
                        break;
                }       
                case Rectangle2:
                {
                        GFX_FillStyleSet(GFX_INDEX_0, GFX_FILL_STYLE_COLOR);
                        GFX_ColorSet(GFX_INDEX_0, GFX_RGBConvert(0x00, 0x00, 0xF8));
                        GFX_RectangleFillDraw(GFX_INDEX_0,
                                                                  95,  // p1x
                                                                  60,  // p1y
                                                                  225,  // p2x
                                                                  180); // p2y
                        
                        GFX_ColorSet(GFX_INDEX_0, GFX_RGBConvert(0x00, 0x00, 0xF8));
                        GFX_LineStyleSet(GFX_INDEX_0, GFX_LINE_STYLE_THIN_SOLID);
                        GFX_RectangleDraw(GFX_INDEX_0,
                                                          95,  // p1x
                                                          60,  // p1y
                                                          225,  // p2x
                                                          180); // p2y
                        
                        break;
                }       
                case Circle10:
                {
                        GFX_ColorSet(GFX_INDEX_0,GFX_RGBConvert(0xF8, 0x00, 0x00));
                        GFX_LineStyleSet(GFX_INDEX_0, GFX_LINE_STYLE_THIN_SOLID);
                        GFX_CircleDraw(GFX_INDEX_0,
                                                   160, // p1x
                                                   120, // p1y
                                                   3); // radius
                                                   
                        break;
                }       
                case Circle9:
                {
                        GFX_ColorSet(GFX_INDEX_0,GFX_RGBConvert(0xF8, 0x00, 0x00));
                        GFX_LineStyleSet(GFX_INDEX_0, GFX_LINE_STYLE_THIN_SOLID);
                        GFX_CircleDraw(GFX_INDEX_0,
                                                   160, // p1x
                                                   120, // p1y
                                                   16); // radius
                                                   
                        break;
                }       
                case Circle8:
                {
                        GFX_ColorSet(GFX_INDEX_0,GFX_RGBConvert(0xF8, 0x00, 0x00));
                        GFX_LineStyleSet(GFX_INDEX_0, GFX_LINE_STYLE_THIN_SOLID);
                        GFX_CircleDraw(GFX_INDEX_0,
                                                   160, // p1x
                                                   120, // p1y
                                                   29); // radius
                                                   
                        break;
                }       
                case Circle7:
                {
                        GFX_ColorSet(GFX_INDEX_0,GFX_RGBConvert(0xF8, 0x00, 0x00));
                        GFX_LineStyleSet(GFX_INDEX_0, GFX_LINE_STYLE_THIN_SOLID);
                        GFX_CircleDraw(GFX_INDEX_0,
                                                   160, // p1x
                                                   120, // p1y
                                                   42); // radius
                                                   
                        break;
                }       
                case Circle6:
                {
                        GFX_ColorSet(GFX_INDEX_0,GFX_RGBConvert(0xF8, 0x00, 0x00));
                        GFX_LineStyleSet(GFX_INDEX_0, GFX_LINE_STYLE_THIN_SOLID);
                        GFX_CircleDraw(GFX_INDEX_0,
                                                   160, // p1x
                                                   120, // p1y
                                                   55); // radius
                                                   
                        break;
                }       
                case Circle5:
                {
                        GFX_ColorSet(GFX_INDEX_0,GFX_RGBConvert(0xF8, 0x00, 0x00));
                        GFX_LineStyleSet(GFX_INDEX_0, GFX_LINE_STYLE_THIN_SOLID);
                        GFX_CircleDraw(GFX_INDEX_0,
                                                   160, // p1x
                                                   120, // p1y
                                                   68); // radius
                                                   
                        break;
                }       
                case Circle4:
                {
                        GFX_ColorSet(GFX_INDEX_0,GFX_RGBConvert(0xF8, 0x00, 0x00));
                        GFX_LineStyleSet(GFX_INDEX_0, GFX_LINE_STYLE_THIN_SOLID);
                        GFX_CircleDraw(GFX_INDEX_0,
                                                   160, // p1x
                                                   120, // p1y
                                                   81); // radius
                                                   
                        break;
                }       
                case Circle3:
                {
                        GFX_ColorSet(GFX_INDEX_0,GFX_RGBConvert(0xF8, 0x00, 0x00));
                        GFX_LineStyleSet(GFX_INDEX_0, GFX_LINE_STYLE_THIN_SOLID);
                        GFX_CircleDraw(GFX_INDEX_0,
                                                   160, // p1x
                                                   120, // p1y
                                                   94); // radius
                                                   
                        break;
                }       
                case Circle2:
                {
                        GFX_ColorSet(GFX_INDEX_0,GFX_RGBConvert(0xF8, 0x00, 0x00));
                        GFX_LineStyleSet(GFX_INDEX_0, GFX_LINE_STYLE_THIN_SOLID);
                        GFX_CircleDraw(GFX_INDEX_0,
                                                   160, // p1x
                                                   120, // p1y
                                                   107); // radius
                                                   
                        break;
                }       
                case Circle1:
                {
                        GFX_ColorSet(GFX_INDEX_0,GFX_RGBConvert(0xF8, 0x00, 0x00));
                        GFX_LineStyleSet(GFX_INDEX_0, GFX_LINE_STYLE_THIN_SOLID);
                        GFX_CircleDraw(GFX_INDEX_0,
                                                   160, // p1x
                                                   120, // p1y
                                                   120); // radius
                                                   
                        break;
                }       
        default:
                return false; // process by default
    }

    return true;
}

/******************************************************************************
  Function: 
    bool GFX_HGC_MsgStaticTexts(uint16_t objMsg, GFX_GOL_OBJ_HEADER *pObj)

  Output:
    Returns true if a Object ID matches an existing item identifier

  Remarks: 
    Handles GFX GOL Static Text events
 */
bool GFX_HGC_MsgStaticTexts(uint16_t objMsg, GFX_GOL_OBJ_HEADER *pObj)
{
    switch (GFX_GOL_ObjectIDGet(pObj))
    {
        default:
            return false; // default false as it is not processed
    }    
}

/******************************************************************************
  Function: 
    bool GFX_HGC_MsgPictures(uint16_t objMsg, GFX_GOL_OBJ_HEADER *pObj)

  Output:
    Returns true if a Object ID matches an existing item identifier

  Remarks: 
    Handles GFX GOL Picture Control events
 */
bool GFX_HGC_MsgPictures(uint16_t objMsg, GFX_GOL_OBJ_HEADER *pObj)
{
    switch (GFX_GOL_ObjectIDGet(pObj))
    {
        default:
            return false; // default false as it is not processed
    }    
}




//以下、gfx_hgc_definitions.h
//-----------------------------------------------------------------------------
/*******************************************************************************
  MPLAB Harmony Graphics Composer Generated Definitions Header

  File Name:
    gfx_hgc_definitions.h

  Summary:
    Build-time generated definitions header based on output by the MPLAB Harmony
    Graphics Composer.

  Description:
    Build-time generated definitions header based on output by the MPLAB Harmony
    Graphics Composer.

    Created with MPLAB Harmony Version 1.05
*******************************************************************************/

// DOM-IGNORE-BEGIN
/*******************************************************************************
Copyright (c) 2013-2014 released Microchip Technology Inc.  All rights reserved.

Microchip licenses to you the right to use, modify, copy and distribute
Software only when embedded on a Microchip microcontroller or digital signal
controller that is integrated into your product or third party product
(pursuant to the sublicense terms in the accompanying license agreement).

You should refer to the license agreement accompanying this Software for
additional information regarding your rights and obligations.

SOFTWARE AND DOCUMENTATION ARE PROVIDED AS IS WITHOUT WARRANTY OF ANY KIND,
EITHER EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION, ANY WARRANTY OF
MERCHANTABILITY, TITLE, NON-INFRINGEMENT AND FITNESS FOR A PARTICULAR PURPOSE.
IN NO EVENT SHALL MICROCHIP OR ITS LICENSORS BE LIABLE OR OBLIGATED UNDER
CONTRACT, NEGLIGENCE, STRICT LIABILITY, CONTRIBUTION, BREACH OF WARRANTY, OR
OTHER LEGAL EQUITABLE THEORY ANY DIRECT OR INDIRECT DAMAGES OR EXPENSES
INCLUDING BUT NOT LIMITED TO ANY INCIDENTAL, SPECIAL, INDIRECT, PUNITIVE OR
CONSEQUENTIAL DAMAGES, LOST PROFITS OR LOST DATA, COST OF PROCUREMENT OF
SUBSTITUTE GOODS, TECHNOLOGY, SERVICES, OR ANY CLAIMS BY THIRD PARTIES
(INCLUDING BUT NOT LIMITED TO ANY DEFENSE THEREOF), OR OTHER SIMILAR COSTS.
*******************************************************************************/
// DOM-IGNORE-END


#ifndef _GFX_HGC_DEFINITIONS_H
#define _GFX_HGC_DEFINITIONS_H

#include "system_config.h"
#include "system_definitions.h"

typedef enum
{
    HGC_STATE_INIT = 0,
    HGC_STATE_RUNNING
} HGC_STATES;

typedef enum
{
    HGC_SCREEN_STATE_INIT = 0,
    HGC_SCREEN_STATE_SETUP_SCREEN_screen1,
    HGC_SCREEN_STATE_PRE_DRAW_GOL_SCREEN_screen1,
    HGC_SCREEN_STATE_DRAW_GOL_SCREEN_screen1,
    HGC_SCREEN_STATE_POST_DRAW_GOL_SCREEN_screen1,
    HGC_SCREEN_STATE_PRE_DRAW_PRIMITIVE_SCREEN_screen1,
    HGC_SCREEN_STATE_DRAW_PRIMITIVE_SCREEN_screen1,
    HGC_SCREEN_STATE_POST_DRAW_PRIMITIVE_SCREEN_screen1,
    HGC_SCREEN_STATE_DISPLAY_SCREEN_screen1,
        
    HGC_SCREEN_STATE_SETUP_SCREEN_screen2,
    HGC_SCREEN_STATE_PRE_DRAW_GOL_SCREEN_screen2,
    HGC_SCREEN_STATE_DRAW_GOL_SCREEN_screen2,
    HGC_SCREEN_STATE_POST_DRAW_GOL_SCREEN_screen2,
    HGC_SCREEN_STATE_PRE_DRAW_PRIMITIVE_SCREEN_screen2,
    HGC_SCREEN_STATE_DRAW_PRIMITIVE_SCREEN_screen2,
    HGC_SCREEN_STATE_POST_DRAW_PRIMITIVE_SCREEN_screen2,
    HGC_SCREEN_STATE_DISPLAY_SCREEN_screen2,
        
    HGC_SCREEN_STATE_SETUP_SCREEN_screen3,
    HGC_SCREEN_STATE_PRE_DRAW_GOL_SCREEN_screen3,
    HGC_SCREEN_STATE_DRAW_GOL_SCREEN_screen3,
    HGC_SCREEN_STATE_POST_DRAW_GOL_SCREEN_screen3,
    HGC_SCREEN_STATE_PRE_DRAW_PRIMITIVE_SCREEN_screen3,
    HGC_SCREEN_STATE_DRAW_PRIMITIVE_SCREEN_screen3,
    HGC_SCREEN_STATE_POST_DRAW_PRIMITIVE_SCREEN_screen3,
    HGC_SCREEN_STATE_DISPLAY_SCREEN_screen3,
        
} HGC_SCREEN_STATES;

/*** GFX GOL Scheme Definitions ***/

#define GFX_SCHEME_NAME_0                       "default"
#define GFX_SCHEME_ALPHA_0                      100

#define GFX_SCHEME_BACKGROUND_OFFSET_TOP_0      0
#define GFX_SCHEME_BACKGROUND_OFFSET_LEFT_0     0

#define GFX_SCHEME_PRIMARY_COLOR_RED_0          0x00
#define GFX_SCHEME_PRIMARY_COLOR_GREEN_0        0x00
#define GFX_SCHEME_PRIMARY_COLOR_BLUE_0         0x00

#define GFX_SCHEME_SECONDARY_COLOR_RED_0        0x40
#define GFX_SCHEME_SECONDARY_COLOR_GREEN_0      0x40
#define GFX_SCHEME_SECONDARY_COLOR_BLUE_0       0x40

#define GFX_SCHEME_DISABLED_COLOR_RED_0         0x00
#define GFX_SCHEME_DISABLED_COLOR_GREEN_0       0x00
#define GFX_SCHEME_DISABLED_COLOR_BLUE_0        0x00

#define GFX_SCHEME_BACKGROUND_COLOR_RED_0       0x00
#define GFX_SCHEME_BACKGROUND_COLOR_GREEN_0     0x00
#define GFX_SCHEME_BACKGROUND_COLOR_BLUE_0      0x00

#define GFX_SCHEME_EMBOSS_SIZE_0                3

#define GFX_SCHEME_EMBOSS_LIGHT_COLOR_RED_0     0x00
#define GFX_SCHEME_EMBOSS_LIGHT_COLOR_GREEN_0   0x00
#define GFX_SCHEME_EMBOSS_LIGHT_COLOR_BLUE_0    0x00

#define GFX_SCHEME_EMBOSS_DARK_COLOR_RED_0      0x00
#define GFX_SCHEME_EMBOSS_DARK_COLOR_GREEN_0    0x00
#define GFX_SCHEME_EMBOSS_DARK_COLOR_BLUE_0     0x00

#define GFX_SCHEME_TEXT_PRIMARY_COLOR_RED_0     0xF8
#define GFX_SCHEME_TEXT_PRIMARY_COLOR_GREEN_0   0xFC
#define GFX_SCHEME_TEXT_PRIMARY_COLOR_BLUE_0    0xF8

#define GFX_SCHEME_TEXT_SECONDARY_COLOR_RED_0   0x00
#define GFX_SCHEME_TEXT_SECONDARY_COLOR_GREEN_0 0x00
#define GFX_SCHEME_TEXT_SECONDARY_COLOR_BLUE_0  0x00

#define GFX_SCHEME_TEXT_DISABLED_COLOR_RED_0    0x40
#define GFX_SCHEME_TEXT_DISABLED_COLOR_GREEN_0  0x40
#define GFX_SCHEME_TEXT_DISABLED_COLOR_BLUE_0   0x40

#define GFX_SCHEME_GRADIENT_START_COLOR_RED_0    0x00
#define GFX_SCHEME_GRADIENT_START_COLOR_GREEN_0  0x00
#define GFX_SCHEME_GRADIENT_START_COLOR_BLUE_0   0x00

#define GFX_SCHEME_GRADIENT_END_COLOR_RED_0    0x00
#define GFX_SCHEME_GRADIENT_END_COLOR_GREEN_0  0x00
#define GFX_SCHEME_GRADIENT_END_COLOR_BLUE_0   0x00

#define GFX_SCHEME_FILL_STYLE_0                GFX_FILL_STYLE_COLOR
#define GFX_SCHEME_BACKGROUND_TYPE_0           GFX_BACKGROUND_NONE

                
/*** GFX GOL Button Definitions ***/
#define GFX_STATICTEXT_LEFT_0            13
#define GFX_STATICTEXT_TOP_0             141
#define GFX_STATICTEXT_RIGHT_0           131
#define GFX_STATICTEXT_BOTTOM_0          191
#define GFX_STATICTEXT_STATE_0          GFX_GOL_STATICTEXT_DRAW_STATE
#define GFX_STATICTEXT_TEXT_0            "0x31, 0x36, 0x62, 0x69, 0x74, 0x20, 0x42, 0x50, 0x50, 0x0"
#define GFX_STATICTEXT_ALIGNMENT_0       GFX_ALIGN_LEFT | GFX_ALIGN_TOP
#define GFX_STATICTEXT_SCHEME_0          gfxScheme0
                
/*** static text IDs ***/
#define StaticText1                  700 
        
/*** GFX GOL windows Definitions ***/
#define GFX_PICTURE_LEFT_0            7
#define GFX_PICTURE_TOP_0             8
#define GFX_PICTURE_RIGHT_0           107
#define GFX_PICTURE_BOTTOM_0          137
#define GFX_PICTURE_STATE_0          GFX_GOL_PICTURECONTROL_DRAW_STATE
#define GFX_PICTURE_SCALE_0       1
#define GFX_PICTURE_SCHEME_0          gfxScheme0
                
/*** Pictures IDs ***/
#define Picture1                  800 
        
/*** Line IDs ***/
#define Line11                 950 
        
#define Line10                 951 
        
#define Line9                 952 
        
#define Line8                 953 
        
#define Line7                 954 
        
#define Line6                 955 
        
#define Line5                 956 
        
#define Line4                 957 
        
#define Line3                 958 
        
#define Line2                 959 
        
#define Line1                 960 
        
/*** Rectangle IDs ***/
#define Rectangle5                 1000 
        
#define Rectangle4                 1001 
        
#define Rectangle1                 1002 
        
#define Rectangle3                 1003 
        
#define Rectangle2                 1004 
        
/*** Circle IDs ***/
#define Circle10                 1050 

#define Circle9                 1051 
        
#define Circle8                 1052 
        
#define Circle7                 1053 
        
#define Circle6                 1054 
        
#define Circle5                 1055 
        
#define Circle4                 1056 
        
#define Circle3                 1057 
        
#define Circle2                 1058 
        
#define Circle1                 1059 
        
/*** Screen IDs ***/
#define screen1                 0 
        
#define screen2                 1 

#define screen3                 2 



// *****************************************************************************
/* MPLAB Harmony Graphics Composer Objects

  Summary:
    Structure holding the graphics object handles

  Description:
    This structure contains the object handles for all graphics objects 
    generated by the Harmony Graphics Composer

  Remarks:
*/

typedef struct HGC_OBJECTS
{
    HGC_SCREEN_STATES screenState;      // current state of screen state machine
    HGC_SCREEN_STATES prevRefreshState; // previous state of screen state machine

//    DRV_TOUCH_SAMPLE_POINTS samplePoints;

    /*** GOL Objects References ***/
    GFX_GOL_STATICTEXT* pStaticText1Obj;
    GFX_GOL_PICTURECONTROL* pPicture1Obj;
} HGC_OBJECTS;

extern HGC_OBJECTS hgcObj;

/******************************************************************************
  Function:
    void GFX_HGC_Setup ( void )

  Summary:
    This function sets up the GOL message callback and draw callbacks.  
 */
void GFX_HGC_Setup ( void );


/******************************************************************************
  Function:
    HGC_SCREEN_STATES GFX_HGC_GetScreenState ( void )

  Remarks:
    This function returns the screen state
 */
HGC_SCREEN_STATES GFX_HGC_GetScreenState ( void );


/******************************************************************************
  Function:
    void GFX_HGC_SetScreenState ( HGC_SCREEN_STATES newState )

  Remarks:
    This function sets the screen state machine to a new state
 */
void GFX_HGC_SetScreenState ( HGC_SCREEN_STATES newState );


/******************************************************************************
  Function:
    void GFX_HGC_Tasks (SYS_MODULE_OBJ gfxObject);

  Summary:
    This function is called in SYS_Tasks.  The intent wait until the GFX library
    is initialized before supplying items to draw
*/
void GFX_HGC_Tasks  (SYS_MODULE_OBJ gfxObject);


/******************************************************************************
  Function:
    void GFX_HGC_SchemeCreate ( void )

  Summary:
    Allocates memory for a new scheme
 */
GFX_GOL_OBJ_SCHEME *GFX_HGC_SchemeCreate(void);


/******************************************************************************
  Function:
    void GFX_HGC_InitializeSchemes ( void )

  Summary:
    Initializes all HGC-specified schemes
 */
void GFX_HGC_InitializeSchemes( void );


/******************************************************************************
  Function: 
    bool GFX_HGC_MESSAGECallback(uint16_t objMsg, GFX_GOL_OBJ_HEADER* pObj, GFX_GOL_MESSAGE* pMsg)

  Input: 
    objMsg - translated message for the object,
    pObj - pointer to the object,
    pMsg - pointer to the non-translated, raw GOL message

  Output: 
    If the function returns non-zero the message will be processed by default

  Remarks: 
    GFX_GOL_MESSAGECallback() function calls it each time the valid message for the GOL object is received.
 */
bool GFX_HGC_MessageCallback(GFX_GOL_TRANSLATED_ACTION objMsg, GFX_GOL_OBJ_HEADER *pObj, GFX_GOL_MESSAGE *pMsg);


/******************************************************************************
  Function: 
    bool GFX_HGC_DrawCallback( void )

  Output: 
    If the function returns non-zero the draw control will be passed to GOL

  Remarks: 
    GFX_GOL_Draw() function calls it each time when GOL objects drawing is 
    completed. HGC-specified draw data is grouped by screens states. It takes 
    two states to complete the drawing of each screen.  GFX GOL objects are drawn
    first and then GFX Primitives are drawn next to ensure primitives are not
    covered by GOL objects.
 */
bool GFX_HGC_DrawCallback( void );
/******************************************************************************
  Function: 
    bool GFX_HGC_DrawScreen_GOL( uint8_t  screenId )

  Output: 
    Returns true if a screenId matches an existing screen identifier

  Remarks: 
    HGC-specified GFX GOL objects are drawn here, grouped by screen.
    The draw order is reverse Z-ordered.
 */
bool GFX_HGC_DrawScreen_GOL(uint8_t screenId);


/******************************************************************************
  Function: 
    bool GFX_HGC_DrawScreen_Primitives( uint8_t  screenId )

  Output:
    Returns true if a screenId matches an existing screen identifier

  Remarks: 
    HGC-specified GFX Primitives are drawn here, grouped by screen.
    GFX Primitives are drawn after GFX GOL Objects to make sure GFX GOL Objects
    do not cover GFX Primitives
 */
bool GFX_HGC_DrawScreen_Primitives(uint8_t screenId);


/******************************************************************************
  Function: 
    void GFX_HGC_SetupScreen( uint8_t  screenId )

  Remarks: 
    Clears current screen and starts a fresh screen with its background color
 */
void GFX_HGC_SetupScreen(uint8_t screenId);


/******************************************************************************
  Function: 
    bool GFX_HGC_ChangeScreen( uint8_t  screenId )

  Output: 
    Returns true if a screenId matches an existing screen identifier

  Remarks: 
    Can be called to initiate GFX Library to draw a new screen
 */
bool GFX_HGC_ChangeScreen(uint8_t screenId);


/******************************************************************************
  Function: 
    bool GFX_HGC_DrawItem(int itemId)

  Output:
    Returns true if a itemId matches an existing item identifier

  Remarks: 
    Every item specified in every screen in HGC is listed in this function
 */
bool GFX_HGC_DrawItem(int itemId);


/******************************************************************************
  Function: 
    bool GFX_HGC_MsgPictures(uint16_t objMsg, GFX_GOL_OBJ_HEADER *pObj)

  Output:
    Returns true if a Object ID matches an existing item identifier

  Remarks: 
    Handles GFX GOL Picture Control events
 */
bool GFX_HGC_MsgPictures(uint16_t objMsg, GFX_GOL_OBJ_HEADER *pObj);

/******************************************************************************
  Function: 
    bool GFX_HGC_MsgStaticTexts(uint16_t objMsg, GFX_GOL_OBJ_HEADER *pObj)

  Output:
    Returns true if a Object ID matches an existing item identifier

  Remarks: 
    Handles GFX GOL Static Text events
 */
bool GFX_HGC_MsgStaticTexts(uint16_t objMsg, GFX_GOL_OBJ_HEADER *pObj);

#endif // _GFX_HGC_DEFINITIONS_H
/*******************************************************************************
 End of File
*/




//以下、system_config.h
//------------------------------------------------------------------------

/*******************************************************************************
  MPLAB Harmony System Configuration Header

  File Name:
    system_config.h

  Summary:
    Build-time configuration header for the system defined by this MPLAB Harmony
    project.

  Description:
    An MPLAB Project may have multiple configurations.  This file defines the
    build-time options for a single configuration.

  Remarks:
    This configuration header must not define any prototypes or data
    definitions (or include any files that do).  It only provides macro
    definitions for build-time configuration options that are not instantiated
    until used by another MPLAB Harmony module or application.
    
    Created with MPLAB Harmony Version 1.05
*******************************************************************************/

// DOM-IGNORE-BEGIN
/*******************************************************************************
Copyright (c) 2013-2015 released Microchip Technology Inc.  All rights reserved.

Microchip licenses to you the right to use, modify, copy and distribute
Software only when embedded on a Microchip microcontroller or digital signal
controller that is integrated into your product or third party product
(pursuant to the sublicense terms in the accompanying license agreement).

You should refer to the license agreement accompanying this Software for
additional information regarding your rights and obligations.

SOFTWARE AND DOCUMENTATION ARE PROVIDED AS IS WITHOUT WARRANTY OF ANY KIND,
EITHER EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION, ANY WARRANTY OF
MERCHANTABILITY, TITLE, NON-INFRINGEMENT AND FITNESS FOR A PARTICULAR PURPOSE.
IN NO EVENT SHALL MICROCHIP OR ITS LICENSORS BE LIABLE OR OBLIGATED UNDER
CONTRACT, NEGLIGENCE, STRICT LIABILITY, CONTRIBUTION, BREACH OF WARRANTY, OR
OTHER LEGAL EQUITABLE THEORY ANY DIRECT OR INDIRECT DAMAGES OR EXPENSES
INCLUDING BUT NOT LIMITED TO ANY INCIDENTAL, SPECIAL, INDIRECT, PUNITIVE OR
CONSEQUENTIAL DAMAGES, LOST PROFITS OR LOST DATA, COST OF PROCUREMENT OF
SUBSTITUTE GOODS, TECHNOLOGY, SERVICES, OR ANY CLAIMS BY THIRD PARTIES
(INCLUDING BUT NOT LIMITED TO ANY DEFENSE THEREOF), OR OTHER SIMILAR COSTS.
*******************************************************************************/
// DOM-IGNORE-END

#ifndef _SYSTEM_CONFIG_H
#define _SYSTEM_CONFIG_H

/* This is a temporary workaround for an issue with the peripheral library "Exists"
   functions that causes superfluous warnings.  It "nulls" out the definition of
   The PLIB function attribute that causes the warning.  Once that issue has been
   resolved, this definition should be removed. */
#define _PLIB_UNSUPPORTED


// *****************************************************************************
// *****************************************************************************
// Section: Included Files
// *****************************************************************************
// *****************************************************************************
/*  This section Includes other configuration headers necessary to completely
    define this configuration.
*/


// *****************************************************************************
// *****************************************************************************
// Section: System Service Configuration
// *****************************************************************************
// *****************************************************************************

// *****************************************************************************
/* Common System Service Configuration Options
*/
#define SYS_VERSION_STR           "1.05"
#define SYS_VERSION               10500

// *****************************************************************************
/* Clock System Service Configuration Options
*/
#define SYS_CLK_FREQ                        200000000ul
#define SYS_CLK_BUS_PERIPHERAL_1            100000000ul
#define SYS_CLK_BUS_PERIPHERAL_2            100000000ul
#define SYS_CLK_BUS_PERIPHERAL_3            100000000ul
#define SYS_CLK_BUS_PERIPHERAL_4            100000000ul
#define SYS_CLK_BUS_PERIPHERAL_5            100000000ul
#define SYS_CLK_BUS_PERIPHERAL_7            200000000ul
#define SYS_CLK_BUS_PERIPHERAL_8            100000000ul
#define SYS_CLK_CONFIG_PRIMARY_XTAL         24000000ul
#define SYS_CLK_CONFIG_SECONDARY_XTAL       0ul
   
/*** Ports System Service Configuration ***/
#define SYS_PORT_C_ANSEL        0xe01e
#define SYS_PORT_C_TRIS         0xf01e
#define SYS_PORT_C_LAT          0x0
#define SYS_PORT_C_ODC          0x0
#define SYS_PORT_C_CNPU         0x0
#define SYS_PORT_C_CNPD         0x0
#define SYS_PORT_C_CNEN         0x0

// *****************************************************************************
// *****************************************************************************
// Section: Driver Configuration
// *****************************************************************************
// *****************************************************************************

#define  GFX_USE_DISPLAY_CONTROLLER_INT035
 //#define  GFX_USE_DISPLAY_CONTROLLER_SSD1926

#define USE_16BIT_PMP
//#define USE_8BIT_PMP


// *****************************************************************************
// *****************************************************************************
// Section: Middleware & Other Library Configuration
// *****************************************************************************
// *****************************************************************************



/*** GFX Library Configuration ***/

#define GFX_INSTANCES_NUMBER                            1
#define GFX_SELF_PREEMPTION_LEVEL                       0
#define GFX_CONFIG_COLOR_DEPTH                          16

#define GFX_CONFIG_FONT_CHAR_SIZE                       8
#define GFX_CONFIG_FONT_EXTERNAL_DISABLE
#define GFX_CONFIG_FONT_RAM_DISABLE
#define GFX_CONFIG_IMAGE_EXTERNAL_DISABLE
#define GFX_CONFIG_IMAGE_RAM_DISABLE
#define GFX_CONFIG_GRADIENT_DISABLE
#define GFX_CONFIG_PALETTE_DISABLE
#define GFX_CONFIG_FONT_ANTIALIASED_DISABLE
#define GFX_CONFIG_TRANSPARENT_COLOR_DISABLE
#define GFX_CONFIG_PALETTE_EXTERNAL_DISABLE
#define GFX_CONFIG_DOUBLE_BUFFERING_DISABLE
#define GFX_CONFIG_USE_KEYBOARD_DISABLE
#define GFX_CONFIG_USE_TOUCHSCREEN_DISABLE
#define GFX_CONFIG_FOCUS_DISABLE
#define GFX_malloc(size)                                    malloc(size)
#define GFX_free(pObj)                                      free(pObj)


#endif // _SYSTEM_CONFIG_H
/*******************************************************************************
 End of File
*/


//以下、system_definitions.h
//-----------------------------------------------------------------------------
/*******************************************************************************
  System Definitions

  File Name:
    system_definitions.h

  Summary:
    MPLAB Harmony project system definitions.

  Description:
    This file contains the system-wide prototypes and definitions for an MPLAB
    Harmony project.
 *******************************************************************************/

//DOM-IGNORE-BEGIN
/*******************************************************************************
Copyright (c) 2013-2014 released Microchip Technology Inc.  All rights reserved.

Microchip licenses to you the right to use, modify, copy and distribute
Software only when embedded on a Microchip microcontroller or digital signal
controller that is integrated into your product or third party product
(pursuant to the sublicense terms in the accompanying license agreement).

You should refer to the license agreement accompanying this Software for
additional information regarding your rights and obligations.

SOFTWARE AND DOCUMENTATION ARE PROVIDED AS IS WITHOUT WARRANTY OF ANY KIND,
EITHER EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION, ANY WARRANTY OF
MERCHANTABILITY, TITLE, NON-INFRINGEMENT AND FITNESS FOR A PARTICULAR PURPOSE.
IN NO EVENT SHALL MICROCHIP OR ITS LICENSORS BE LIABLE OR OBLIGATED UNDER
CONTRACT, NEGLIGENCE, STRICT LIABILITY, CONTRIBUTION, BREACH OF WARRANTY, OR
OTHER LEGAL EQUITABLE THEORY ANY DIRECT OR INDIRECT DAMAGES OR EXPENSES
INCLUDING BUT NOT LIMITED TO ANY INCIDENTAL, SPECIAL, INDIRECT, PUNITIVE OR
CONSEQUENTIAL DAMAGES, LOST PROFITS OR LOST DATA, COST OF PROCUREMENT OF
SUBSTITUTE GOODS, TECHNOLOGY, SERVICES, OR ANY CLAIMS BY THIRD PARTIES
(INCLUDING BUT NOT LIMITED TO ANY DEFENSE THEREOF), OR OTHER SIMILAR COSTS.
 *******************************************************************************/
//DOM-IGNORE-END

#ifndef _SYS_DEFINITIONS_H
#define _SYS_DEFINITIONS_H


// *****************************************************************************
// *****************************************************************************
// Section: Included Files
// *****************************************************************************
// *****************************************************************************

#include <stdint.h>
#include <stddef.h>
#include <stdbool.h>
#include "system/common/sys_common.h"
#include "system/common/sys_module.h"
#include "system/clk/sys_clk.h"
#include "system/clk/sys_clk_static.h"
#include "system/devcon/sys_devcon.h"
#include "system/console/sys_console.h"

#include "framework/driver/pmp/drv_pmp_static.h"
#include "driver/tmr/drv_tmr_static.h"
#include "peripheral/int/plib_int.h"
#include "system/ports/sys_ports.h"
#include "gfx/gfx.h"
#include "gfx/gfx_gol.h"
#include "gfx/gfx_gol_scheme.h"


#include "drv_gfx_INT035.h"     //INT035用
//#include "driver/gfx/controller/ssd1926/drv_gfx_ssd1926.h"
#include "system/debug/sys_debug.h"
#include "system/command/sys_command.h"


#include "gfx_hgc_definitions.h"
#include "app.h"


// *****************************************************************************
// *****************************************************************************
// Section: Type Definitions
// *****************************************************************************
// *****************************************************************************

// *****************************************************************************
/* System Objects

  Summary:
    Structure holding the system's object handles

  Description:
    This structure contains the object handles for all objects in the
    MPLAB Harmony project's system configuration.

  Remarks:
    These handles are returned from the "Initialize" functions for each module
    and must be passed into the "Tasks" function for each module.
*/

typedef struct
{
    SYS_MODULE_OBJ  sysDevcon;
    SYS_MODULE_OBJ  gfxObject0;
    
} SYSTEM_OBJECTS;


// *****************************************************************************
// *****************************************************************************
// Section: extern declarations
// *****************************************************************************
// *****************************************************************************

extern SYSTEM_OBJECTS sysObj;

#endif /* _SYS_DEFINITIONS_H */
/*******************************************************************************
 End of File
*/


//-----------------------------------------------------------------------------


 
<動作結果>
  1. ピクチャー

 表示モード  液晶INT035の画面
 画面@  
 画面A  
 画面B  

2.. 動画 ----> YouTube


■ マイクロチップ デモソフト”Primitive”  at PIC32MZ + INT043 

   
  <試作品仕様>
   ・ Harmonyのグラフィックライブラリのサンプルデモソフトとして マイクロチップから提供されている
      ”Primitive"(C:\microchip\harmony\v1_05\apps\gfx\primitive)を
     下記ハードウェアで実行する
      @ PIC: PIC32MZ2048EFH100
      A 液晶: (株)ディスプレーテック INT043-TS WQVGA、3.5インチ
   
   ・ 開発環境  Harmony ver.1.06、  XC32 ver.1.40、  MPLABX 3.06  PIC32MZ2048EFH  revison 1
  

  <試作品回路図>(→回路図のPDFファイル



<試作品外観>下記の写真には上記回路図にはない、また本テーマと関係のない部品が多々写っています



   

          

   <プログラム例>

//以下、main.c
//---------------------------------------------------------------------------------
/*******************************************************************************
  MPLAB Harmony Project Main Source File

  Company:
    Microchip Technology Inc.
  
  File Name:
    main.c

  Summary:
    This file contains the "main" function for an MPLAB Harmony project.

  Description:
    This file contains the "main" function for an MPLAB Harmony project.  The
    "main" function calls the "SYS_Initialize" function to initialize the state 
    machines of all MPLAB Harmony modules in the system and it calls the 
    "SYS_Tasks" function from within a system-wide "super" loop to maintain 
    their correct operation. These two functions are implemented in 
    configuration-specific files (usually "system_init.c" and "system_tasks.c")
    in a configuration-specific folder under the "src/system_config" folder 
    within this project's top-level folder.  An MPLAB Harmony project may have
    more than one configuration, each contained within it's own folder under
    the "system_config" folder.
 *******************************************************************************/

// DOM-IGNORE-BEGIN
/*******************************************************************************
Copyright (c) 2013-2014 released Microchip Technology Inc.  All rights reserved.

//Microchip licenses to you the right to use, modify, copy and distribute
Software only when embedded on a Microchip microcontroller or digital signal
controller that is integrated into your product or third party product
(pursuant to the sublicense terms in the accompanying license agreement).

You should refer to the license agreement accompanying this Software for
additional information regarding your rights and obligations.

SOFTWARE AND DOCUMENTATION ARE PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND,
EITHER EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION, ANY WARRANTY OF
MERCHANTABILITY, TITLE, NON-INFRINGEMENT AND FITNESS FOR A PARTICULAR PURPOSE.
IN NO EVENT SHALL MICROCHIP OR ITS LICENSORS BE LIABLE OR OBLIGATED UNDER
CONTRACT, NEGLIGENCE, STRICT LIABILITY, CONTRIBUTION, BREACH OF WARRANTY, OR
OTHER LEGAL EQUITABLE THEORY ANY DIRECT OR INDIRECT DAMAGES OR EXPENSES
INCLUDING BUT NOT LIMITED TO ANY INCIDENTAL, SPECIAL, INDIRECT, PUNITIVE OR
CONSEQUENTIAL DAMAGES, LOST PROFITS OR LOST DATA, COST OF PROCUREMENT OF
SUBSTITUTE GOODS, TECHNOLOGY, SERVICES, OR ANY CLAIMS BY THIRD PARTIES
(INCLUDING BUT NOT LIMITED TO ANY DEFENSE THEREOF), OR OTHER SIMILAR COSTS.
 *******************************************************************************/
// DOM-IGNORE-END


// *****************************************************************************
// *****************************************************************************
// Section: Included Files
// *****************************************************************************
// *****************************************************************************

#include <stddef.h>                     // Defines NULL
#include <stdbool.h>                    // Defines true
#include <stdlib.h>                     // Defines EXIT_FAILURE
#include "system/common/sys_module.h"   // SYS function prototypes


// *****************************************************************************
// *****************************************************************************
// Section: Main Entry Point
// *****************************************************************************
// *****************************************************************************

int main ( void )
{
    /* Initialize all MPLAB Harmony modules, including application(s). */
    SYS_Initialize ( NULL );


    while ( true )
    {
        /* Maintain state machines of all polled MPLAB Harmony modules. */
        SYS_Tasks ( );

    }

    /* Execution should not come here during normal operation */

    return ( EXIT_FAILURE );
}


/*******************************************************************************
 End of File
*/



//以下、app.c
//-------------------------------------------------------------------------
/*******************************************************************************
  MPLAB Harmony Application Source File
  
  Company:
    Microchip Technology Inc.
  
  File Name:
    app.c

  Summary:
    This file contains the source code for the MPLAB Harmony application.

  Description:
    This file contains the source code for the MPLAB Harmony application.  It 
    implements the logic of the application's state machine and it may call 
    API routines of other MPLAB Harmony modules in the system, such as drivers,
    system services, and middleware.  However, it does not call any of the
    system interfaces (such as the "Initialize" and "Tasks" functions) of any of
    the modules in the system or make any assumptions about when those functions
    are called.  That is the responsibility of the configuration-specific system
    files.
 *******************************************************************************/

// DOM-IGNORE-BEGIN
/*******************************************************************************
Copyright (c) 2013-2014 released Microchip Technology Inc.  All rights reserved.

Microchip licenses to you the right to use, modify, copy and distribute
Software only when embedded on a Microchip microcontroller or digital signal
controller that is integrated into your product or third party product
(pursuant to the sublicense terms in the accompanying license agreement).

You should refer to the license agreement accompanying this Software for
additional information regarding your rights and obligations.

SOFTWARE AND DOCUMENTATION ARE PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND,
EITHER EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION, ANY WARRANTY OF
MERCHANTABILITY, TITLE, NON-INFRINGEMENT AND FITNESS FOR A PARTICULAR PURPOSE.
IN NO EVENT SHALL MICROCHIP OR ITS LICENSORS BE LIABLE OR OBLIGATED UNDER
CONTRACT, NEGLIGENCE, STRICT LIABILITY, CONTRIBUTION, BREACH OF WARRANTY, OR
OTHER LEGAL EQUITABLE THEORY ANY DIRECT OR INDIRECT DAMAGES OR EXPENSES
INCLUDING BUT NOT LIMITED TO ANY INCIDENTAL, SPECIAL, INDIRECT, PUNITIVE OR
CONSEQUENTIAL DAMAGES, LOST PROFITS OR LOST DATA, COST OF PROCUREMENT OF
SUBSTITUTE GOODS, TECHNOLOGY, SERVICES, OR ANY CLAIMS BY THIRD PARTIES
(INCLUDING BUT NOT LIMITED TO ANY DEFENSE THEREOF), OR OTHER SIMILAR COSTS.
 *******************************************************************************/
// DOM-IGNORE-END


// *****************************************************************************
// *****************************************************************************
// Section: Included Files 
// *****************************************************************************
// *****************************************************************************

#include "app.h"
#include "1lcd_lib_C32.h"


int delay_Clock = 200000000;   //200MHz

void delay_us(volatile unsigned int usec)        //1μsec遅延
{
        volatile  int count;

        count = (int)(delay_Clock/20000000)*usec;


        do      //実測 at 200MH (Clock=200000000)
        {       //delay_us(1000):1000.4μsec  delay_us(100):100.6μsec  delay_us(10):10.5μsec  delay_us(1):1.5μsec
                asm("NOP"); asm("NOP"); asm("NOP"); asm("NOP"); asm("NOP");asm("NOP");
                asm("NOP"); asm("NOP"); asm("NOP"); asm("NOP"); asm("NOP"); asm("NOP");

                count--;
        }while(count != 0);


}

void delay_ms(volatile unsigned int msec)        //1msec遅延
{
        volatile unsigned int i;         //実測:at200MH (Clock=200000000)//delay_ms(1): 1.0006msec   delay_ms(100):100.04msec

        for(i=0; i<msec; i++)
        delay_us(1000);
}




// *****************************************************************************
// *****************************************************************************
// Section: Global Data Definitions
// *****************************************************************************
// *****************************************************************************

// *****************************************************************************
/* Application Data

  Summary:
    Holds application data

  Description:
    This structure holds the application's data.

  Remarks:
    This structure should be initialized by the APP_Initialize function.
    
    Application strings and buffers are be defined outside this structure.
*/

APP_DATA appData;





// *****************************************************************************
// *****************************************************************************
// Section: MACROS
// *****************************************************************************
// *****************************************************************************
#define MIN(x,y)                ((x > y)? y: x)
#define APP_SCREEN_DELAY_MS         (1000)
// *****************************************************************************
// *****************************************************************************
// Section: Global Variable Definitions
// *****************************************************************************
// *****************************************************************************

// *****************************************************************************
// *****************************************************************************
// Section: Application Local Routines
// *****************************************************************************
void APP_TMR_DelayMS ( unsigned int delayMs );


// *****************************************************************************
// *****************************************************************************
// Section: Application Callback Functions
// *****************************************************************************
// *****************************************************************************

/* TODO:  Add any necessary callback funtions.
*/

// *****************************************************************************
// *****************************************************************************
// Section: Application Local Functions
// *****************************************************************************
// *****************************************************************************

/* TODO:  Add any necessary local functions.
*/


// *****************************************************************************
// *****************************************************************************
// Section: Application Initialization and State Machine Functions
// *****************************************************************************
// *****************************************************************************

/*******************************************************************************
  Function:
    void APP_Initialize ( void )

  Remarks:
    See prototype in app.h.
 */

void APP_Initialize ( void )
{
    /* Place the App state machine in its initial state. */
    appData.state = APP_STATE_INIT;
    
    /* TODO: Initialize your application's state machine and other
     * parameters.
     */
}


/******************************************************************************
  Function:
    void APP_Tasks ( void )

  Remarks:
    See prototype in app.h.
 */

void APP_Tasks ( void )
{
    /* Check the application's current state. */
    switch ( appData.state )
    {
        /* Application's initial state. */
        case APP_STATE_INIT:
        {
            appData.state = APP_HGC_SCREEN1_DRAW;
            break;
        }
        
        case APP_HGC_SCREEN1_DRAW:
        {
            if(hgcObj.screenState != HGC_SCREEN_STATE_DISPLAY_SCREEN_screen1)
                return;
            
            GFX_HGC_ChangeScreen(screen2);
        //    APP_TMR_DelayMS(5000); 
            APP_TMR_DelayMS(1000);
            appData.state = APP_HGC_SCREEN2_DRAW;
            break;
        }    

        case APP_HGC_SCREEN2_DRAW:
        {
            if(hgcObj.screenState != HGC_SCREEN_STATE_DISPLAY_SCREEN_screen2)
                return;
            
            GFX_HGC_ChangeScreen(screen3);
         //    APP_TMR_DelayMS(5000); 
            APP_TMR_DelayMS(1000);
            appData.state = APP_HGC_SCREEN3_DRAW;
            break;
        }
        
        case APP_HGC_SCREEN3_DRAW:
        {
            if(hgcObj.screenState != HGC_SCREEN_STATE_DISPLAY_SCREEN_screen3)
                return;
            
            GFX_HGC_ChangeScreen(screen1);
          //    APP_TMR_DelayMS(5000);
            APP_TMR_DelayMS(1000);
            appData.state = APP_HGC_SCREEN1_DRAW;
            break;
        }    

        /* The default state should never be executed. */
        default:
        {
            /* TODO: Handle error in application's state machine. */
            break;
        }
    }
}

void APP_TMR_DelayMS ( unsigned int delayMs )
{
    if(delayMs)
    {
        uint32_t sysClk = SYS_CLK_FREQ;
        uint32_t t0;
        t0 = _CP0_GET_COUNT();
        while (_CP0_GET_COUNT() - t0 < (sysClk/2000)*delayMs);
    }
}

/*******************************************************************************
 End of File
 */





//以下、system_init.c
//-----------------------------------------------------------------------------
/*******************************************************************************
  System Initialization File

  File Name:
    system_init.c

  Summary:
    This file contains source code necessary to initialize the system.

  Description:
    This file contains source code necessary to initialize the system.  It
    implements the "SYS_Initialize" function, defines the configuration bits, 
    and allocates any necessary global system resources, such as the 
    sysObj structure that contains the object handles to all the MPLAB Harmony 
    module objects in the system.
 *******************************************************************************/

// DOM-IGNORE-BEGIN
/*******************************************************************************
Copyright (c) 2013-2015 released Microchip Technology Inc.  All rights reserved.

Microchip licenses to you the right to use, modify, copy and distribute
Software only when embedded on a Microchip microcontroller or digital signal
controller that is integrated into your product or third party product
(pursuant to the sublicense terms in the accompanying license agreement).

You should refer to the license agreement accompanying this Software for
additional information regarding your rights and obligations.

SOFTWARE AND DOCUMENTATION ARE PROVIDED AS IS WITHOUT WARRANTY OF ANY KIND,
EITHER EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION, ANY WARRANTY OF
MERCHANTABILITY, TITLE, NON-INFRINGEMENT AND FITNESS FOR A PARTICULAR PURPOSE.
IN NO EVENT SHALL MICROCHIP OR ITS LICENSORS BE LIABLE OR OBLIGATED UNDER
CONTRACT, NEGLIGENCE, STRICT LIABILITY, CONTRIBUTION, BREACH OF WARRANTY, OR
OTHER LEGAL EQUITABLE THEORY ANY DIRECT OR INDIRECT DAMAGES OR EXPENSES
INCLUDING BUT NOT LIMITED TO ANY INCIDENTAL, SPECIAL, INDIRECT, PUNITIVE OR
CONSEQUENTIAL DAMAGES, LOST PROFITS OR LOST DATA, COST OF PROCUREMENT OF
SUBSTITUTE GOODS, TECHNOLOGY, SERVICES, OR ANY CLAIMS BY THIRD PARTIES
(INCLUDING BUT NOT LIMITED TO ANY DEFENSE THEREOF), OR OTHER SIMILAR COSTS.
 *******************************************************************************/
// DOM-IGNORE-END


// *****************************************************************************
// *****************************************************************************
// Section: Included Files
// *****************************************************************************
// *****************************************************************************

#include "system_config.h"
#include "system_definitions.h"


// ****************************************************************************
// ****************************************************************************
// Section: Configuration Bits
// ****************************************************************************
// ****************************************************************************
// <editor-fold defaultstate="collapsed" desc="Configuration Bits">

/*** DEVCFG0 ***/

#pragma config DEBUG =      OFF
#pragma config JTAGEN =     OFF
#pragma config ICESEL =     ICS_PGx1
#pragma config TRCEN =      OFF
#pragma config BOOTISA =    MIPS32
#pragma config FECCCON =    OFF_UNLOCKED
#pragma config FSLEEP =     OFF
#pragma config DBGPER =     PG_ALL
#pragma config EJTAGBEN =   NORMAL
#pragma config CP =         OFF

/*** DEVCFG1 ***/

#pragma config FNOSC =      SPLL
#pragma config DMTINTV =    WIN_127_128
#pragma config FSOSCEN =    OFF
#pragma config IESO =       OFF
#pragma config POSCMOD =    EC
#pragma config OSCIOFNC =   OFF
#pragma config FCKSM =      CSECME
#pragma config WDTPS =      PS1048576
#pragma config WDTSPGM =    STOP
#pragma config FWDTEN =     OFF
#pragma config WINDIS =     NORMAL
#pragma config FWDTWINSZ =  WINSZ_25
#pragma config DMTCNT =     DMT31
#pragma config FDMTEN =     OFF

/*** DEVCFG2 ***/

#pragma config FPLLIDIV =   DIV_3
#pragma config FPLLRNG =    RANGE_5_10_MHZ

//#pragma config FPLLICLK = PLL_FRC   //内蔵高速発振器選択    //★★★ バグ有 主発振回路選択の時、FPLLICLK = PLL_POSCではなくFPLLICLK = PLL_FRCを選択する。(at ver.1.33 XC32)
#pragma config FPLLICLK =   PLL_POSC
#pragma config FPLLMULT =   MUL_50
#pragma config FPLLODIV =   DIV_2
#pragma config UPLLFSEL =   FREQ_24MHZ
//#pragma config UPLLEN =     ON

/*** DEVCFG3 ***/

#pragma config USERID =     0xffff
#pragma config FMIIEN =     ON
#pragma config FETHIO =     ON
#pragma config PGL1WAY =    ON
#pragma config PMDL1WAY =   ON
#pragma config IOL1WAY =    ON
#pragma config FUSBIDIO =   ON

/*** BF1SEQ0 ***/

#pragma config TSEQ =       0xffff
#pragma config CSEQ =       0xffff
// </editor-fold>


// *****************************************************************************
// *****************************************************************************
// Section: Library/Stack Initialization Data
// *****************************************************************************
// *****************************************************************************



// *****************************************************************************
// *****************************************************************************
// Section: Driver Initialization Data
// *****************************************************************************
// *****************************************************************************


// </editor-fold>

DRV_GFX_INIT drvGfxInit =
{
    .orientation             = DISP_ORIENTATION,
    .horizontalResolution    = DISP_HOR_RESOLUTION,
    .verticalResolution      = DISP_VER_RESOLUTION,
    
/*
    .dataWidth               = DISP_DATA_WIDTH,
    .horizontalPulseWidth    = DISP_HOR_PULSE_WIDTH,
    .horizontalBackPorch     = DISP_HOR_BACK_PORCH,
    .horizontalFrontPorch    = DISP_HOR_FRONT_PORCH,
    .verticalPulseWidth      = DISP_VER_PULSE_WIDTH,
    .verticalBackPorch       = DISP_VER_BACK_PORCH,
    .verticalFrontPorch      = DISP_VER_FRONT_PORCH,
    .logicShift              = DISP_INV_LSHIFT,
    .LCDType                 = 1,
    .colorType               = 0,
    .TCON_Init               = TCON_MODULE,
 */ 
    
};





// *****************************************************************************
// *****************************************************************************
// Section: System Data
// *****************************************************************************
// *****************************************************************************

/* Structure to hold the object handles for the modules in the system. */
SYSTEM_OBJECTS sysObj;


// *****************************************************************************
// *****************************************************************************
// Section: Module Initialization Data
// *****************************************************************************
// *****************************************************************************

/*** GFX Initialization Data ***/

 const GFX_INIT gfxInit0 =
{
    .drvInitialize    = NULL,
    
   
    .drvOpen          = DRV_GFX_INT043_Open,
    .drvInterfaceSet  = DRV_GFX_INT043_InterfaceSet, 
 //   .drvOpen          = DRV_GFX_INT035_Open,
 //   .drvInterfaceSet  = DRV_GFX_INT035_InterfaceSet, 
  //  .drvOpen          = DRV_GFX_SSD1926_Open,
  //  .drvInterfaceSet  = DRV_GFX_SSD1926_InterfaceSet,
};

/*******************************************************************************
  Device Control System Service Initialization Data
  
  <editor-fold defaultstate="collapsed" 
  desc="Device Control System Service Initialization Data">
*/

const SYS_DEVCON_INIT sysDevconInit =
{
    .moduleInit = {0},
};

// </editor-fold>


// *****************************************************************************
// *****************************************************************************
// Section: Static Initialization Functions
// *****************************************************************************
// *****************************************************************************


// *****************************************************************************
// *****************************************************************************
// Section: System Initialization
// *****************************************************************************
// *****************************************************************************




void ys_PMP_Initialize(void)
{

    short pClockPeriod = 1000000000 / 100000000;
    
    // PMP setup
    PMMODE = 0;
    PMAEN = 0;
    PMCON = 0;
    PMMODEbits.MODE = 2;                // Intel 8080 master interface

    #if (PMP_DATA_SETUP_TIME == 0)
        PMMODEbits.WAITB = 0;
    #else
        if (PMP_DATA_SETUP_TIME <= pClockPeriod)
            PMMODEbits.WAITB = 0;
        else if (PMP_DATA_SETUP_TIME > pClockPeriod)
            PMMODEbits.WAITB = (PMP_DATA_SETUP_TIME / pClockPeriod) + 1;
    #endif

    #if (PMP_DATA_WAIT_TIME == 0)
        PMMODEbits.WAITM = 0;
    #else
        if (PMP_DATA_WAIT_TIME <= pClockPeriod)
            PMMODEbits.WAITM = 1;
        else if (PMP_DATA_WAIT_TIME > pClockPeriod)
            PMMODEbits.WAITM = (PMP_DATA_WAIT_TIME / pClockPeriod) + 1;
    #endif

    #if (PMP_DATA_HOLD_TIME == 0)
        PMMODEbits.WAITE = 0;
    #else
        if (PMP_DATA_HOLD_TIME <= pClockPeriod)
            PMMODEbits.WAITE = 0;
        else if (PMP_DATA_HOLD_TIME > pClockPeriod)
            PMMODEbits.WAITE = (PMP_DATA_HOLD_TIME / pClockPeriod) + 1;
    #endif

    #if defined(USE_16BIT_PMP)
    PMMODEbits.MODE16 = 1;              // 16 bit mode
    #elif defined(USE_8BIT_PMP)
    PMMODEbits.MODE16 = 0;              // 8 bit mode
    #endif

    PMCONbits.PTRDEN = 1;               // enable RD line
    PMCONbits.PTWREN = 1;               // enable WR line
    PMCONbits.PMPEN = 1;                // enable PMP

    delay_us(200);



}






/*******************************************************************************
  Function:
    void SYS_Initialize ( SYS_INIT_DATA *data )

  Summary:
    Initializes the board, services, drivers, application and other modules.

  Remarks:
    See prototype in system/common/sys_module.h.
 */

void SYS_Initialize ( void* data )
{
    /* Core Processor Initialization */
    SYS_CLK_Initialize( NULL );
    sysObj.sysDevcon = SYS_DEVCON_Initialize(SYS_DEVCON_INDEX_0, (SYS_MODULE_INIT*)&sysDevconInit);
    SYS_DEVCON_PerformanceConfig(SYS_CLK_SystemFrequencyGet());
    SYS_PORTS_Initialize();

    /* Initialize Drivers */

    /* Initialize System Services */

      delay_ms(500);  

//PMP 初期化 Initialize PMP0
    ys_PMP_Initialize();
//    DRV_PMP0_Initialize();
//    DRV_PMP0_ModeConfig();

    
//GFX グラフィック初期化
    DRV_GFX_INT043_Initialize(GFX_INDEX_0, (SYS_MODULE_INIT*)&drvGfxInit);
  //  DRV_GFX_INT035_Initialize(GFX_INDEX_0, (SYS_MODULE_INIT*)&drvGfxInit);
    //DRV_GFX_SSD1926_Initialize(GFX_INDEX_0, (SYS_MODULE_INIT*)&drvGfxInit);
   

    /* Initialize Middleware */

    sysObj.gfxObject0 = GFX_Initialize(GFX_INDEX_0, (SYS_MODULE_INIT *)&gfxInit0);
           
    /* Initialize the Application */
    APP_Initialize();
}


/*******************************************************************************
 End of File
*/






//以下、gfx_hgc_definitions.c
//------------------------------------------------------------------------------
/*******************************************************************************
  MPLAB Harmony Graphics Composer Generated Implementation File

  File Name:
    gfx_hgc_definitions.c

  Summary:
    Build-time generated implementation from the MPLAB Harmony
    Graphics Composer.

  Description:
    Build-time generated implementation from the MPLAB Harmony
    Graphics Composer.

    Created with MPLAB Harmony Version 1.05
*******************************************************************************/
// DOM-IGNORE-BEGIN
/*******************************************************************************
Copyright (c) 2013-2014 released Microchip Technology Inc.  All rights reserved.

Microchip licenses to you the right to use, modify, copy and distribute
Software only when embedded on a Microchip microcontroller or digital signal
controller that is integrated into your product or third party product
(pursuant to the sublicense terms in the accompanying license agreement).

You should refer to the license agreement accompanying this Software for
additional information regarding your rights and obligations.

SOFTWARE AND DOCUMENTATION ARE PROVIDED AS IS WITHOUT WARRANTY OF ANY KIND,
EITHER EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION, ANY WARRANTY OF
MERCHANTABILITY, TITLE, NON-INFRINGEMENT AND FITNESS FOR A PARTICULAR PURPOSE.
IN NO EVENT SHALL MICROCHIP OR ITS LICENSORS BE LIABLE OR OBLIGATED UNDER
CONTRACT, NEGLIGENCE, STRICT LIABILITY, CONTRIBUTION, BREACH OF WARRANTY, OR
OTHER LEGAL EQUITABLE THEORY ANY DIRECT OR INDIRECT DAMAGES OR EXPENSES
INCLUDING BUT NOT LIMITED TO ANY INCIDENTAL, SPECIAL, INDIRECT, PUNITIVE OR
CONSEQUENTIAL DAMAGES, LOST PROFITS OR LOST DATA, COST OF PROCUREMENT OF
SUBSTITUTE GOODS, TECHNOLOGY, SERVICES, OR ANY CLAIMS BY THIRD PARTIES
(INCLUDING BUT NOT LIMITED TO ANY DEFENSE THEREOF), OR OTHER SIMILAR COSTS.
*******************************************************************************/
// DOM-IGNORE-END

#include "gfx_hgc_definitions.h"

/*** Default GFX GOL Scheme ***/
#define GFX_SCHEMEDEFAULT GOLSchemeDefault
extern GFX_GOL_OBJ_SCHEME GFX_SCHEMEDEFAULT;

/*** HGC-specified GFX GOL Scheme ***/
static GFX_GOL_OBJ_SCHEME *gfxScheme0;

/*** Generated Asset References ***/
extern const GFX_RESOURCE_HDR flower16bit;
extern const GFX_RESOURCE_HDR fireflysung;

/*** Generated ASCII Text Labels ***/
static const GFX_XCHAR staticTextStr_0[] = { 0x31, 0x36, 0x62, 0x69, 0x74, 0x20, 0x42, 0x50, 0x50, 0x0 }; // 16bit BPP
/*** HGC Object Global ***/
HGC_OBJECTS hgcObj;
static HGC_STATES hgcState;

/******************************************************************************
  Function:
    HGC_SCREEN_STATES GFX_HGC_GetScreenState ( void )

  Remarks:
    This function returns the screen state
 */
HGC_SCREEN_STATES GFX_HGC_GetScreenState ( void )
{
    return hgcObj.screenState;
}


/******************************************************************************
  Function:
    void GFX_HGC_SetScreenState ( HGC_SCREEN_STATES newState )

  Remarks:
    This function sets the screen state machine to a new state
 */
void GFX_HGC_SetScreenState ( HGC_SCREEN_STATES newState )
{
    hgcObj.prevRefreshState = hgcObj.screenState;
    hgcObj.screenState = newState;
}


/******************************************************************************
  Function:
    void GFX_HGC_Setup ( void )

  Summary:
    This function sets up the GOL message callback and draw callbacks.  
 */
void GFX_HGC_Setup ( void )
{
    GFX_GOL_MessageCallbackSet(GFX_INDEX_0, &GFX_HGC_MessageCallback);
    GFX_GOL_DrawCallbackSet(GFX_INDEX_0, &GFX_HGC_DrawCallback);

    GFX_HGC_InitializeSchemes();

}

/******************************************************************************
  Function:
    void GFX_HGC_Tasks (SYS_MODULE_OBJ gfxObject);

  Summary:
    This function is called in SYS_Tasks.  The intent wait until the GFX library
    is initialized before supplying items to draw
*/
void GFX_HGC_Tasks  (SYS_MODULE_OBJ gfxObject)
{
    switch ( hgcState )
    {
        case HGC_STATE_INIT:
            if (GFX_Status(gfxObject)==SYS_STATUS_READY)
            {
                GFX_HGC_Setup();
                hgcState = HGC_STATE_RUNNING;
            }
            break;

        case HGC_STATE_RUNNING:
            break;

        default:
            break;
    }
}

/******************************************************************************
  Function:
    void GFX_HGC_SchemeCreate ( void )

  Summary:
    Allocates memory for a new scheme
 */
GFX_GOL_OBJ_SCHEME *GFX_HGC_SchemeCreate(void)
{
    GFX_GOL_OBJ_SCHEME  *pTemp;

    pTemp = (GFX_GOL_OBJ_SCHEME *)GFX_malloc(sizeof(GFX_GOL_OBJ_SCHEME));

    if(pTemp != NULL)
    {
        memcpy(pTemp, &GFX_SCHEMEDEFAULT, sizeof(GFX_GOL_OBJ_SCHEME));
    }

    return (pTemp);
}

/******************************************************************************
  Function:
    void GFX_HGC_InitializeSchemes ( void )

  Summary:
    Initializes all HGC-specified schemes
 */
void GFX_HGC_InitializeSchemes( void )
{
    gfxScheme0 = GFX_HGC_SchemeCreate();

#ifndef GFX_CONFIG_ALPHABLEND_DISABLE
    gfxScheme0->AlphaValue =        GFX_SCHEME_ALPHA_0;
#endif
    gfxScheme0->Color0 =            GFX_RGBConvert(GFX_SCHEME_PRIMARY_COLOR_RED_0, GFX_SCHEME_PRIMARY_COLOR_GREEN_0, GFX_SCHEME_PRIMARY_COLOR_BLUE_0);
    gfxScheme0->Color1 =            GFX_RGBConvert(GFX_SCHEME_SECONDARY_COLOR_RED_0, GFX_SCHEME_SECONDARY_COLOR_GREEN_0, GFX_SCHEME_SECONDARY_COLOR_BLUE_0);
    gfxScheme0->ColorDisabled =     GFX_RGBConvert(GFX_SCHEME_DISABLED_COLOR_RED_0, GFX_SCHEME_DISABLED_COLOR_GREEN_0, GFX_SCHEME_DISABLED_COLOR_BLUE_0);
    gfxScheme0->CommonBkColor =     GFX_RGBConvert(GFX_SCHEME_BACKGROUND_COLOR_RED_0, GFX_SCHEME_BACKGROUND_COLOR_GREEN_0, GFX_SCHEME_BACKGROUND_COLOR_BLUE_0);
        gfxScheme0->EmbossSize =        GFX_SCHEME_EMBOSS_SIZE_0;
    gfxScheme0->EmbossDkColor =     GFX_RGBConvert(GFX_SCHEME_EMBOSS_DARK_COLOR_RED_0, GFX_SCHEME_EMBOSS_DARK_COLOR_GREEN_0, GFX_SCHEME_EMBOSS_DARK_COLOR_BLUE_0);
    gfxScheme0->EmbossLtColor =     GFX_RGBConvert(GFX_SCHEME_EMBOSS_LIGHT_COLOR_RED_0, GFX_SCHEME_EMBOSS_LIGHT_COLOR_GREEN_0, GFX_SCHEME_EMBOSS_LIGHT_COLOR_BLUE_0);
        gfxScheme0->TextColor0 =        GFX_RGBConvert(GFX_SCHEME_TEXT_PRIMARY_COLOR_RED_0, GFX_SCHEME_TEXT_PRIMARY_COLOR_GREEN_0, GFX_SCHEME_TEXT_PRIMARY_COLOR_BLUE_0);
    gfxScheme0->TextColor1 =        GFX_RGBConvert(GFX_SCHEME_TEXT_SECONDARY_COLOR_RED_0, GFX_SCHEME_TEXT_SECONDARY_COLOR_GREEN_0, GFX_SCHEME_TEXT_SECONDARY_COLOR_BLUE_0);
    gfxScheme0->TextColorDisabled = GFX_RGBConvert(GFX_SCHEME_TEXT_DISABLED_COLOR_RED_0, GFX_SCHEME_TEXT_DISABLED_COLOR_GREEN_0, GFX_SCHEME_TEXT_DISABLED_COLOR_BLUE_0);
#ifndef GFX_CONFIG_GRADIENT_DISABLE
        gfxScheme0->gradientStartColor = GFX_RGBConvert(GFX_SCHEME_GRADIENT_START_COLOR_RED_0, GFX_SCHEME_GRADIENT_START_COLOR_GREEN_0, GFX_SCHEME_GRADIENT_START_COLOR_BLUE_0);
        gfxScheme0->gradientEndColor = GFX_RGBConvert(GFX_SCHEME_GRADIENT_END_COLOR_RED_0, GFX_SCHEME_GRADIENT_END_COLOR_GREEN_0, GFX_SCHEME_GRADIENT_END_COLOR_BLUE_0);
#endif
    gfxScheme0->CommonBkLeft =      GFX_SCHEME_BACKGROUND_OFFSET_TOP_0;
    gfxScheme0->CommonBkTop =       GFX_SCHEME_BACKGROUND_OFFSET_LEFT_0;
    gfxScheme0->pFont =             (GFX_RESOURCE_HDR*)&fireflysung;
    gfxScheme0->pCommonBkImage =    (GFX_RESOURCE_HDR*)NULL;
        
        gfxScheme0->fillStyle =         GFX_SCHEME_FILL_STYLE_0;
        gfxScheme0->CommonBkType =      GFX_SCHEME_BACKGROUND_TYPE_0;

}

/******************************************************************************
  Function: 
    bool GFX_HGC_MESSAGECallback(uint16_t objMsg, GFX_GOL_OBJ_HEADER* pObj, GFX_GOL_MESSAGE* pMsg)

  Input: 
    objMsg - translated message for the object,
    pObj - pointer to the object,
    pMsg - pointer to the non-translated, raw GOL message

  Output: 
    If the function returns non-zero the message will be processed by default

  Remarks: 
    GFX_GOL_MESSAGECallback() function calls it each time the valid message for the GOL object is received.
 */
bool GFX_HGC_MessageCallback(GFX_GOL_TRANSLATED_ACTION objMsg, GFX_GOL_OBJ_HEADER *pObj, GFX_GOL_MESSAGE *pMsg)
{
    // process messages for demo screens
    switch (hgcObj.screenState)
    {
        case HGC_SCREEN_STATE_DISPLAY_SCREEN_screen1:
            if (GFX_HGC_MsgPictures(objMsg, pObj) == true)
                return true;
            if (GFX_HGC_MsgStaticTexts(objMsg, pObj) == true)
                return true;
            break;
        case HGC_SCREEN_STATE_DISPLAY_SCREEN_screen2:
            if (GFX_HGC_MsgPictures(objMsg, pObj) == true)
                return true;
            if (GFX_HGC_MsgStaticTexts(objMsg, pObj) == true)
                return true;
            break;
        case HGC_SCREEN_STATE_DISPLAY_SCREEN_screen3:
            if (GFX_HGC_MsgPictures(objMsg, pObj) == true)
                return true;
            if (GFX_HGC_MsgStaticTexts(objMsg, pObj) == true)
                return true;
            break;
      default:
            // process message by default
            return true;
    }
    return true;
}

/******************************************************************************
  Function: 
    bool GFX_HGC_DrawCallback( void )

  Output: 
    If the function returns non-zero the draw control will be passed to GOL

  Remarks: 
    GFX_GOL_Draw() function calls it each time when GOL objects drawing is 
    completed. HGC-specified draw data is grouped by screens states. It takes 
    two states to complete the drawing of each screen.  GFX GOL objects are drawn
    first and then GFX Primitives are drawn next to ensure primitives are not
    covered by GOL objects.
 */
bool GFX_HGC_DrawCallback( void )
{
    switch (hgcObj.screenState)
    {
        case HGC_SCREEN_STATE_INIT:
            //Draw the primary screen as selected in the Composer
            GFX_HGC_SetScreenState(HGC_SCREEN_STATE_SETUP_SCREEN_screen1);
            return true;
        case HGC_SCREEN_STATE_SETUP_SCREEN_screen1:
            GFX_HGC_SetScreenState(HGC_SCREEN_STATE_PRE_DRAW_GOL_SCREEN_screen1);
            break;
        case HGC_SCREEN_STATE_PRE_DRAW_GOL_SCREEN_screen1:
            GFX_HGC_SetScreenState(HGC_SCREEN_STATE_DRAW_GOL_SCREEN_screen1);
            break;
        case HGC_SCREEN_STATE_DRAW_GOL_SCREEN_screen1:
            GFX_HGC_SetupScreen(screen1);
            GFX_HGC_DrawScreen_GOL(screen1);
            GFX_HGC_SetScreenState(HGC_SCREEN_STATE_POST_DRAW_GOL_SCREEN_screen1);
            break;
        case HGC_SCREEN_STATE_POST_DRAW_GOL_SCREEN_screen1:
            GFX_HGC_SetScreenState(HGC_SCREEN_STATE_PRE_DRAW_PRIMITIVE_SCREEN_screen1);
            break;
        case HGC_SCREEN_STATE_PRE_DRAW_PRIMITIVE_SCREEN_screen1:
            GFX_HGC_SetScreenState(HGC_SCREEN_STATE_DRAW_PRIMITIVE_SCREEN_screen1);
            break;
        case HGC_SCREEN_STATE_DRAW_PRIMITIVE_SCREEN_screen1:
            GFX_HGC_DrawScreen_Primitives(screen1);
            GFX_HGC_SetScreenState(HGC_SCREEN_STATE_POST_DRAW_PRIMITIVE_SCREEN_screen1);
            break;
        case HGC_SCREEN_STATE_POST_DRAW_PRIMITIVE_SCREEN_screen1:
            GFX_HGC_SetScreenState(HGC_SCREEN_STATE_DISPLAY_SCREEN_screen1);
            break;
        case HGC_SCREEN_STATE_DISPLAY_SCREEN_screen1:
            break;
        case HGC_SCREEN_STATE_SETUP_SCREEN_screen2:
            GFX_HGC_SetScreenState(HGC_SCREEN_STATE_PRE_DRAW_GOL_SCREEN_screen2);
            break;
        case HGC_SCREEN_STATE_PRE_DRAW_GOL_SCREEN_screen2:
            GFX_HGC_SetScreenState(HGC_SCREEN_STATE_DRAW_GOL_SCREEN_screen2);
            break;
        case HGC_SCREEN_STATE_DRAW_GOL_SCREEN_screen2:
            GFX_HGC_SetupScreen(screen2);
            GFX_HGC_DrawScreen_GOL(screen2);
            GFX_HGC_SetScreenState(HGC_SCREEN_STATE_POST_DRAW_GOL_SCREEN_screen2);
            break;
        case HGC_SCREEN_STATE_POST_DRAW_GOL_SCREEN_screen2:
            GFX_HGC_SetScreenState(HGC_SCREEN_STATE_PRE_DRAW_PRIMITIVE_SCREEN_screen2);
            break;
        case HGC_SCREEN_STATE_PRE_DRAW_PRIMITIVE_SCREEN_screen2:
            GFX_HGC_SetScreenState(HGC_SCREEN_STATE_DRAW_PRIMITIVE_SCREEN_screen2);
            break;
        case HGC_SCREEN_STATE_DRAW_PRIMITIVE_SCREEN_screen2:
            GFX_HGC_DrawScreen_Primitives(screen2);
            GFX_HGC_SetScreenState(HGC_SCREEN_STATE_POST_DRAW_PRIMITIVE_SCREEN_screen2);
            break;
        case HGC_SCREEN_STATE_POST_DRAW_PRIMITIVE_SCREEN_screen2:
            GFX_HGC_SetScreenState(HGC_SCREEN_STATE_DISPLAY_SCREEN_screen2);
            break;
        case HGC_SCREEN_STATE_DISPLAY_SCREEN_screen2:
            break;
        case HGC_SCREEN_STATE_SETUP_SCREEN_screen3:
            GFX_HGC_SetScreenState(HGC_SCREEN_STATE_PRE_DRAW_GOL_SCREEN_screen3);
            break;
        case HGC_SCREEN_STATE_PRE_DRAW_GOL_SCREEN_screen3:
            GFX_HGC_SetScreenState(HGC_SCREEN_STATE_DRAW_GOL_SCREEN_screen3);
            break;
        case HGC_SCREEN_STATE_DRAW_GOL_SCREEN_screen3:
            GFX_HGC_SetupScreen(screen3);
            GFX_HGC_DrawScreen_GOL(screen3);
            GFX_HGC_SetScreenState(HGC_SCREEN_STATE_POST_DRAW_GOL_SCREEN_screen3);
            break;
        case HGC_SCREEN_STATE_POST_DRAW_GOL_SCREEN_screen3:
            GFX_HGC_SetScreenState(HGC_SCREEN_STATE_PRE_DRAW_PRIMITIVE_SCREEN_screen3);
            break;
        case HGC_SCREEN_STATE_PRE_DRAW_PRIMITIVE_SCREEN_screen3:
            GFX_HGC_SetScreenState(HGC_SCREEN_STATE_DRAW_PRIMITIVE_SCREEN_screen3);
            break;
        case HGC_SCREEN_STATE_DRAW_PRIMITIVE_SCREEN_screen3:
            GFX_HGC_DrawScreen_Primitives(screen3);
            GFX_HGC_SetScreenState(HGC_SCREEN_STATE_POST_DRAW_PRIMITIVE_SCREEN_screen3);
            break;
        case HGC_SCREEN_STATE_POST_DRAW_PRIMITIVE_SCREEN_screen3:
            GFX_HGC_SetScreenState(HGC_SCREEN_STATE_DISPLAY_SCREEN_screen3);
            break;
        case HGC_SCREEN_STATE_DISPLAY_SCREEN_screen3:
            break;
        default:
            return true; // release drawing control to GOL by default
    }

    return true; // release drawing control to GOL
}

/******************************************************************************
  Function: 
    void GFX_HGC_SetupScreen( uint8_t  screenId )

  Remarks: 
    Clears current screen and starts a fresh screen with its background color
 */
void GFX_HGC_SetupScreen(uint8_t screenId)
{
    switch (screenId)
    {
        case screen1:
            GFX_ColorSet(GFX_INDEX_0, GFX_RGBConvert(0x00, 0x00, 0x00));
            GFX_ScreenClear(GFX_INDEX_0);

            GFX_GOL_ObjectListFree(GFX_INDEX_0); // free memory for the objects in the previous linked list and start new list
            break;
        case screen2:
            GFX_ColorSet(GFX_INDEX_0, GFX_RGBConvert(0x00, 0x00, 0x00));
            GFX_ScreenClear(GFX_INDEX_0);

            GFX_GOL_ObjectListFree(GFX_INDEX_0); // free memory for the objects in the previous linked list and start new list
            break;
        case screen3:
            GFX_ColorSet(GFX_INDEX_0, GFX_RGBConvert(0x00, 0x00, 0x00));
            GFX_ScreenClear(GFX_INDEX_0);

            GFX_GOL_ObjectListFree(GFX_INDEX_0); // free memory for the objects in the previous linked list and start new list
            break;
        default:
            break;
    }
}


/******************************************************************************
  Function: 
    bool GFX_HGC_ChangeScreen( uint8_t  screenId )

  Output: 
    Returns true if a screenId matches an existing screen identifier

  Remarks: 
    Can be called to initiate GFX Library to draw a new screen
 */
bool GFX_HGC_ChangeScreen(uint8_t screenId)
{
    switch (screenId)
    {
        case screen1:
            GFX_HGC_SetScreenState(HGC_SCREEN_STATE_SETUP_SCREEN_screen1);
            break;
        case screen2:
            GFX_HGC_SetScreenState(HGC_SCREEN_STATE_SETUP_SCREEN_screen2);
            break;
        case screen3:
            GFX_HGC_SetScreenState(HGC_SCREEN_STATE_SETUP_SCREEN_screen3);
            break;
        default:
            return false;
    }

    return true; // release drawing control to GOL
}

/******************************************************************************
  Function: 
    bool GFX_HGC_DrawScreen_GOL( uint8_t  screenId )

  Output: 
    Returns true if a screenId matches an existing screen identifier

  Remarks: 
    HGC-specified GFX GOL objects are drawn here, grouped by screen.
    The draw order is reverse Z-ordered.
 */
bool GFX_HGC_DrawScreen_GOL(uint8_t screenId)
{
    switch (screenId)
    {
        case screen1:
            break;
        case screen2:
            GFX_HGC_DrawItem(Picture1);
            GFX_HGC_DrawItem(StaticText1);
            break;
        case screen3:
            break;
        default:
            return false;
    }

    return true; // release drawing control to GOL
}


/******************************************************************************
  Function: 
    bool GFX_HGC_DrawScreen_Primitives( uint8_t  screenId )

  Output:
    Returns true if a screenId matches an existing screen identifier

  Remarks: 
    HGC-specified GFX Primitives are drawn here, grouped by screen.
    GFX Primitives are drawn after GFX GOL Objects to make sure GFX GOL Objects
    do not cover GFX Primitives
 */
bool GFX_HGC_DrawScreen_Primitives(uint8_t screenId)
{
    switch (screenId)
    {
        case screen1:
            GFX_HGC_DrawItem(Circle1);
            GFX_HGC_DrawItem(Circle2);
            GFX_HGC_DrawItem(Circle3);
            GFX_HGC_DrawItem(Circle4);
            GFX_HGC_DrawItem(Circle5);
            GFX_HGC_DrawItem(Circle6);
            GFX_HGC_DrawItem(Circle7);
            GFX_HGC_DrawItem(Circle8);
            GFX_HGC_DrawItem(Circle9);
            GFX_HGC_DrawItem(Circle10);
            GFX_HGC_DrawItem(Line1);
            GFX_HGC_DrawItem(Line2);
            GFX_HGC_DrawItem(Line3);
            GFX_HGC_DrawItem(Line4);
            GFX_HGC_DrawItem(Line5);
            GFX_HGC_DrawItem(Line6);
            GFX_HGC_DrawItem(Line7);
            GFX_HGC_DrawItem(Line8);
            GFX_HGC_DrawItem(Line9);
            GFX_HGC_DrawItem(Line10);
            GFX_HGC_DrawItem(Line11);
            break;
        case screen2:
            break;
        case screen3:
            GFX_HGC_DrawItem(Rectangle2);
            GFX_HGC_DrawItem(Rectangle3);
            GFX_HGC_DrawItem(Rectangle1);
            GFX_HGC_DrawItem(Rectangle4);
            GFX_HGC_DrawItem(Rectangle5);
            break;
        default:
            return true;
    }

    return true; // release drawing control to GOL
}


/******************************************************************************
  Function: 
    bool GFX_HGC_DrawItem(int itemId)

  Output:
    Returns true if a itemId matches an existing item identifier

  Remarks: 
    Every item specified in every screen in HGC is listed in this function
 */
bool GFX_HGC_DrawItem(int itemId)
{
    switch(itemId)
    {
    case StaticText1:
        hgcObj.pStaticText1Obj = GFX_GOL_StaticTextCreate
                (
                 GFX_INDEX_0,
                 StaticText1,      // button ID
                 GFX_STATICTEXT_LEFT_0,    // left
                 GFX_STATICTEXT_TOP_0,     // top
                 GFX_STATICTEXT_RIGHT_0,   // right
                 GFX_STATICTEXT_BOTTOM_0,  // bottom
                 GFX_STATICTEXT_STATE_0,   // state
                 (GFX_XCHAR*)staticTextStr_0,    // text
                 GFX_STATICTEXT_ALIGNMENT_0,       //alignment
                 GFX_STATICTEXT_SCHEME_0
                 ); // use alternate scheme
        break;
    case Picture1:
        hgcObj.pPicture1Obj = GFX_GOL_PictureControlCreate
                (
                 GFX_INDEX_0,
                 Picture1,      // picture ID
                 GFX_PICTURE_LEFT_0,    // left
                 GFX_PICTURE_TOP_0,     // top
                 GFX_PICTURE_RIGHT_0,   // right                                 
                 GFX_PICTURE_BOTTOM_0,  // bottom
                                 GFX_PICTURE_STATE_0,   // state                 
                 GFX_PICTURE_SCALE_0,     // scale
                 (GFX_RESOURCE_HDR*)&flower16bit,    // bitmap
                 GFX_PICTURE_SCHEME_0
                 );
        break;
                case Line11:
                {
                  
                        GFX_ColorSet(GFX_INDEX_0, GFX_RGBConvert(0xF8, 0xFC, 0xF8));
                        GFX_LineStyleSet(GFX_INDEX_0, GFX_LINE_STYLE_THIN_SOLID);
            GFX_LineDraw(GFX_INDEX_0,
                    
                        267*1.5,  // p1x
                                                 0,  // p1y
                                                 53*1.5,  // p2x
                                                 272-1); // p2y
      
                    
                    /*
                                                 267,  // p1x
                                                 0,  // p1y
                                                 53,  // p2x
                                                 239); // p2y
          */
            
       
                        break;
                }               
                case Line10:
                {
            
                        GFX_ColorSet(GFX_INDEX_0, GFX_RGBConvert(0xF8, 0xFC, 0xF8));
                        GFX_LineStyleSet(GFX_INDEX_0, GFX_LINE_STYLE_THIN_SOLID);
                        GFX_LineDraw(GFX_INDEX_0,
               
                                                 214*1.5,  // p1x
                                                 0,  // p1y
                                                 106*1.5,  // p2x
                                                 272-1); // p2y     
                    
             /* 
                                                 214,  // p1x
                                                 0,  // p1y
                                                 106,  // p2x
                                                 239); // p2y
             */ 
                        break;
                }               
                case Line9:
                {
           
                        GFX_ColorSet(GFX_INDEX_0, GFX_RGBConvert(0xF8, 0xFC, 0xF8));
                        GFX_LineStyleSet(GFX_INDEX_0, GFX_LINE_STYLE_THIN_SOLID);
                        GFX_LineDraw(GFX_INDEX_0,
                        106*1.5,  // p1x
                                                 0,  // p1y
                                                 214*1.5,  // p2x
                                                 272-1); // p2y     
                    
              /*       
                                                 106,  // p1x
                                                 0,  // p1y
                                                 214,  // p2x
                                                 239); // p2y
             */ 
                        break;
                }               
                case Line8:
                {
            
                        GFX_ColorSet(GFX_INDEX_0, GFX_RGBConvert(0xF8, 0xFC, 0xF8));
                        GFX_LineStyleSet(GFX_INDEX_0, GFX_LINE_STYLE_THIN_SOLID);
                        GFX_LineDraw(GFX_INDEX_0,
                        53*1.5,  // p1x
                                                 0,  // p1y
                                                 267*1.5,  // p2x
                                                 272-1); // p2y
                    
             /* 
                                                 53,  // p1x
                                                 0,  // p1y
                                                 267,  // p2x
                                                 239); // p2y
             */ 
                        break;
                }               
                case Line7:
                {
            
                        GFX_ColorSet(GFX_INDEX_0, GFX_RGBConvert(0xF8, 0xFC, 0xF8));
                        GFX_LineStyleSet(GFX_INDEX_0, GFX_LINE_STYLE_THIN_SOLID);
                        GFX_LineDraw(GFX_INDEX_0,
                        160*1.5,  // p1x
                                                 0,  // p1y
                                                 160*1.5,  // p2x
                                                 272-1); // p2y     
                    
             /*       
                                                 160,  // p1x
                                                 0,  // p1y
                                                 160,  // p2x
                                                 239); // p2y
             */ 
                        break;
                }               
                case Line6:
                {
            
                        GFX_ColorSet(GFX_INDEX_0, GFX_RGBConvert(0xF8, 0xFC, 0xF8));
                        GFX_LineStyleSet(GFX_INDEX_0, GFX_LINE_STYLE_THIN_SOLID);
                        GFX_LineDraw(GFX_INDEX_0,
                     0,  // p1x
                                                 272-1,  // p1y
                                                 319*1.5,  // p2x
                                                 0); // p2y
                    
                    
            /*
                                                 0,  // p1x
                                                 239,  // p1y
                                                 319,  // p2x
                                                 0); // p2y
             */ 
                        break;
                }               
                case Line5:
                {
            
                        GFX_ColorSet(GFX_INDEX_0, GFX_RGBConvert(0xF8, 0xFC, 0xF8));
                        GFX_LineStyleSet(GFX_INDEX_0, GFX_LINE_STYLE_THIN_SOLID);
                        GFX_LineDraw(GFX_INDEX_0,
                     0,  // p1x
                                                 0,  // p1y
                                                 480-1,  // p2x
                                                 272-1); // p2y
                    
            /*
                                                 0,  // p1x
                                                 0,  // p1y
                                                 319,  // p2x
                                                 239); // p2y
             */ 
                        break;
                }               
                case Line4:
                {
            
                        GFX_ColorSet(GFX_INDEX_0, GFX_RGBConvert(0x00, 0xFC, 0x00));
                        GFX_LineStyleSet(GFX_INDEX_0, GFX_LINE_STYLE_THIN_SOLID);
                        GFX_LineDraw(GFX_INDEX_0,
                        480-1,  // p1x
                                                 0,  // p1y
                                                 480-1,  // p2x
                                                 272-1); // p2y
                    
             /*
                                                 319,  // p1x
                                                 0,  // p1y
                                                 319,  // p2x
                                                 239); // p2y
             */
                        break;
                }               
                case Line3:
                {
            
                        GFX_ColorSet(GFX_INDEX_0, GFX_RGBConvert(0xF8, 0xFC, 0x00));
                        GFX_LineStyleSet(GFX_INDEX_0, GFX_LINE_STYLE_THIN_SOLID);
                        GFX_LineDraw(GFX_INDEX_0,
                        0,  // p1x
                                                 0,  // p1y
                                                 0,  // p2x
                                                 272-1); // p2y
                    
                    
                    
             /* 
                                                 0,  // p1x
                                                 0,  // p1y
                                                 0,  // p2x
                                                 239); // p2y
             */
                        break;
                }               
                case Line2:
                {
            
                        GFX_ColorSet(GFX_INDEX_0, GFX_RGBConvert(0x00, 0x00, 0xF8));
                        GFX_LineStyleSet(GFX_INDEX_0, GFX_LINE_STYLE_THIN_SOLID);
                        GFX_LineDraw(GFX_INDEX_0,
                        0,  // p1x
                                                 272-1,  // p1y
                                                 480-1,  // p2x
                                                 272-1); // p2y
                    
                    
             /* 
                                                 0,  // p1x
                                                 239,  // p1y
                                                 319,  // p2x
                                                 239); // p2y
             */ 
                        break;
                }               
                case Line1:
                {
            
                        GFX_ColorSet(GFX_INDEX_0, GFX_RGBConvert(0xF8, 0x00, 0x00));
                        GFX_LineStyleSet(GFX_INDEX_0, GFX_LINE_STYLE_THIN_SOLID);
                        GFX_LineDraw(GFX_INDEX_0,
                        0,  // p1x
                                                 0,  // p1y
                                                 480-1,  // p2x
                                                 0); // p2y
                    
            /*        
                                                 0,  // p1x
                                                 0,  // p1y
                                                 319,  // p2x
                                                 0); // p2y
             */ 
                        break;
                }               
                case Rectangle5:
                {
                        GFX_ColorSet(GFX_INDEX_0, GFX_RGBConvert(0x00, 0x00, 0xF8));
                        GFX_LineStyleSet(GFX_INDEX_0, GFX_LINE_STYLE_THIN_SOLID);
                        GFX_RectangleDraw(GFX_INDEX_0,
                                                          65+80,  // p1x
                                                          30+16,  // p1y
                                                          255+80,  // p2x
                                                          210+16); // p2y
                        
                        break;
                }       
                case Rectangle4:
                {
                        GFX_ColorSet(GFX_INDEX_0, GFX_RGBConvert(0x00, 0x00, 0xF8));
                        GFX_LineStyleSet(GFX_INDEX_0, GFX_LINE_STYLE_THIN_SOLID);
                        GFX_RectangleDraw(GFX_INDEX_0,
                                                          80+80,  // p1x
                                                          45+16,  // p1y
                                                          240+80,  // p2x
                                                          195+16); // p2y
                        
                        break;
                }       
                case Rectangle1:
                {
                        GFX_FillStyleSet(GFX_INDEX_0, GFX_FILL_STYLE_ALPHA_COLOR);
                        GFX_ColorSet(GFX_INDEX_0, GFX_RGBConvert(0xF8, 0x00, 0x00));
                        GFX_AlphaBlendingValueSet(GFX_INDEX_0, 100);
                        GFX_RectangleFillDraw(GFX_INDEX_0,
                                                                  125+80,  // p1x
                                                                  90+16,  // p1y
                                                                  195+80,  // p2x
                                                                  150+16); // p2y
                        
                        GFX_ColorSet(GFX_INDEX_0, GFX_RGBConvert(0xF8, 0x00, 0x00));
                        GFX_LineStyleSet(GFX_INDEX_0, GFX_LINE_STYLE_THIN_SOLID);
                        GFX_RectangleDraw(GFX_INDEX_0,
                                                          125+80,  // p1x
                                                          90+16,  // p1y
                                                          195+80,  // p2x
                                                          150+16); // p2y
                        
                        break;
                }       
                case Rectangle3:
                {
                        GFX_FillStyleSet(GFX_INDEX_0, GFX_FILL_STYLE_COLOR);
                        GFX_ColorSet(GFX_INDEX_0, GFX_RGBConvert(0x00, 0xFC, 0x00));
                        GFX_RectangleFillDraw(GFX_INDEX_0,
                                                                  110+80,  // p1x
                                                                  75+16,  // p1y
                                                                  210+80,  // p2x
                                                                  165+16); // p2y
                        
                        GFX_ColorSet(GFX_INDEX_0, GFX_RGBConvert(0x00, 0xFC, 0x00));
                        GFX_LineStyleSet(GFX_INDEX_0, GFX_LINE_STYLE_THIN_SOLID);
                        GFX_RectangleDraw(GFX_INDEX_0,
                                                          110+80,  // p1x
                                                          75+16,  // p1y
                                                          210+80,  // p2x
                                                          165+16); // p2y
                        
                        break;
                }       
                case Rectangle2:
                {
                        GFX_FillStyleSet(GFX_INDEX_0, GFX_FILL_STYLE_COLOR);
                        GFX_ColorSet(GFX_INDEX_0, GFX_RGBConvert(0x00, 0x00, 0xF8));
                        GFX_RectangleFillDraw(GFX_INDEX_0,
                                                                  95+80,  // p1x
                                                                  60+16,  // p1y
                                                                  225+80,  // p2x
                                                                  180+16); // p2y
                        
                        GFX_ColorSet(GFX_INDEX_0, GFX_RGBConvert(0x00, 0x00, 0xF8));
                        GFX_LineStyleSet(GFX_INDEX_0, GFX_LINE_STYLE_THIN_SOLID);
                        GFX_RectangleDraw(GFX_INDEX_0,
                                                          95+80,  // p1x
                                                          60+16,  // p1y
                                                          225+80,  // p2x
                                                          180+16); // p2y
                        
                        break;
                }       
                case Circle10:
                {
                        GFX_ColorSet(GFX_INDEX_0,GFX_RGBConvert(0xF8, 0x00, 0x00));
                        GFX_LineStyleSet(GFX_INDEX_0, GFX_LINE_STYLE_THIN_SOLID);
                        GFX_CircleDraw(GFX_INDEX_0,
                                                   480/2,   //160, // p1x
                                                   272/2,   //120, // p1y
                                                   3); // radius
                                                   
                        break;
                }       
                case Circle9:
                {
                        GFX_ColorSet(GFX_INDEX_0,GFX_RGBConvert(0xF8, 0x00, 0x00));
                        GFX_LineStyleSet(GFX_INDEX_0, GFX_LINE_STYLE_THIN_SOLID);
                        GFX_CircleDraw(GFX_INDEX_0,
                                                   480/2,   //160, // p1x
                                                   272/2,   //120, // p1y
                                                   16); // radius
                                                   
                        break;
                }       
                case Circle8:
                {
                        GFX_ColorSet(GFX_INDEX_0,GFX_RGBConvert(0xF8, 0x00, 0x00));
                        GFX_LineStyleSet(GFX_INDEX_0, GFX_LINE_STYLE_THIN_SOLID);
                        GFX_CircleDraw(GFX_INDEX_0,
                                                   480/2,   //160, // p1x
                                                   272/2,   //120, // p1y
                                                   29); // radius
                                                   
                        break;
                }       
                case Circle7:
                {
                        GFX_ColorSet(GFX_INDEX_0,GFX_RGBConvert(0xF8, 0x00, 0x00));
                        GFX_LineStyleSet(GFX_INDEX_0, GFX_LINE_STYLE_THIN_SOLID);
                        GFX_CircleDraw(GFX_INDEX_0,
                                                   480/2,   //160, // p1x
                                                   272/2,   //120, // p1y
                                                   42); // radius
                                                   
                        break;
                }       
                case Circle6:
                {
                        GFX_ColorSet(GFX_INDEX_0,GFX_RGBConvert(0xF8, 0x00, 0x00));
                        GFX_LineStyleSet(GFX_INDEX_0, GFX_LINE_STYLE_THIN_SOLID);
                        GFX_CircleDraw(GFX_INDEX_0,
                                                   480/2,   //160, // p1x
                                                   272/2,   //120, // p1y
                                                   55); // radius
                                                   
                        break;
                }       
                case Circle5:
                {
                        GFX_ColorSet(GFX_INDEX_0,GFX_RGBConvert(0xF8, 0x00, 0x00));
                        GFX_LineStyleSet(GFX_INDEX_0, GFX_LINE_STYLE_THIN_SOLID);
                        GFX_CircleDraw(GFX_INDEX_0,
                                                   480/2,   //160, // p1x
                                                   272/2,   //120, // p1y
                                                   68); // radius
                                                   
                        break;
                }       
                case Circle4:
                {
                        GFX_ColorSet(GFX_INDEX_0,GFX_RGBConvert(0xF8, 0x00, 0x00));
                        GFX_LineStyleSet(GFX_INDEX_0, GFX_LINE_STYLE_THIN_SOLID);
                        GFX_CircleDraw(GFX_INDEX_0,
                                                   480/2,   //160, // p1x
                                                   272/2,   //120, // p1y
                                                   81); // radius
                                                   
                        break;
                }       
                case Circle3:
                {
                        GFX_ColorSet(GFX_INDEX_0,GFX_RGBConvert(0xF8, 0x00, 0x00));
                        GFX_LineStyleSet(GFX_INDEX_0, GFX_LINE_STYLE_THIN_SOLID);
                        GFX_CircleDraw(GFX_INDEX_0,
                                                   480/2,   //160, // p1x
                                                   272/2,   //120, // p1y
                                                   94); // radius
                                                   
                        break;
                }       
                case Circle2:
                {
                        GFX_ColorSet(GFX_INDEX_0,GFX_RGBConvert(0xF8, 0x00, 0x00));
                        GFX_LineStyleSet(GFX_INDEX_0, GFX_LINE_STYLE_THIN_SOLID);
                        GFX_CircleDraw(GFX_INDEX_0,
                                                   480/2,   //160, // p1x
                                                   272/2,   //120, // p1y
                                                   107); // radius
                                                   
                        break;
                }       
                case Circle1:
                {
                        GFX_ColorSet(GFX_INDEX_0,GFX_RGBConvert(0xF8, 0x00, 0x00));
                        GFX_LineStyleSet(GFX_INDEX_0, GFX_LINE_STYLE_THIN_SOLID);
                        GFX_CircleDraw(GFX_INDEX_0,
                                                   480/2,   //160, // p1x
                                                   272/2,   //120, // p1y
                                                   120); // radius
                                                   
                        break;
                }       
        default:
                return false; // process by default
    }

    return true;
}

/******************************************************************************
  Function: 
    bool GFX_HGC_MsgStaticTexts(uint16_t objMsg, GFX_GOL_OBJ_HEADER *pObj)

  Output:
    Returns true if a Object ID matches an existing item identifier

  Remarks: 
    Handles GFX GOL Static Text events
 */
bool GFX_HGC_MsgStaticTexts(uint16_t objMsg, GFX_GOL_OBJ_HEADER *pObj)
{
    switch (GFX_GOL_ObjectIDGet(pObj))
    {
        default:
            return false; // default false as it is not processed
    }    
}

/******************************************************************************
  Function: 
    bool GFX_HGC_MsgPictures(uint16_t objMsg, GFX_GOL_OBJ_HEADER *pObj)

  Output:
    Returns true if a Object ID matches an existing item identifier

  Remarks: 
    Handles GFX GOL Picture Control events
 */
bool GFX_HGC_MsgPictures(uint16_t objMsg, GFX_GOL_OBJ_HEADER *pObj)
{
    switch (GFX_GOL_ObjectIDGet(pObj))
    {
        default:
            return false; // default false as it is not processed
    }    
}




//以下、system_definitions.h
//-----------------------------------------------------------------------------------
/*******************************************************************************
  System Definitions

  File Name:
    system_definitions.h

  Summary:
    MPLAB Harmony project system definitions.

  Description:
    This file contains the system-wide prototypes and definitions for an MPLAB
    Harmony project.
 *******************************************************************************/

//DOM-IGNORE-BEGIN
/*******************************************************************************
Copyright (c) 2013-2014 released Microchip Technology Inc.  All rights reserved.

Microchip licenses to you the right to use, modify, copy and distribute
Software only when embedded on a Microchip microcontroller or digital signal
controller that is integrated into your product or third party product
(pursuant to the sublicense terms in the accompanying license agreement).

You should refer to the license agreement accompanying this Software for
additional information regarding your rights and obligations.

SOFTWARE AND DOCUMENTATION ARE PROVIDED AS IS WITHOUT WARRANTY OF ANY KIND,
EITHER EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION, ANY WARRANTY OF
MERCHANTABILITY, TITLE, NON-INFRINGEMENT AND FITNESS FOR A PARTICULAR PURPOSE.
IN NO EVENT SHALL MICROCHIP OR ITS LICENSORS BE LIABLE OR OBLIGATED UNDER
CONTRACT, NEGLIGENCE, STRICT LIABILITY, CONTRIBUTION, BREACH OF WARRANTY, OR
OTHER LEGAL EQUITABLE THEORY ANY DIRECT OR INDIRECT DAMAGES OR EXPENSES
INCLUDING BUT NOT LIMITED TO ANY INCIDENTAL, SPECIAL, INDIRECT, PUNITIVE OR
CONSEQUENTIAL DAMAGES, LOST PROFITS OR LOST DATA, COST OF PROCUREMENT OF
SUBSTITUTE GOODS, TECHNOLOGY, SERVICES, OR ANY CLAIMS BY THIRD PARTIES
(INCLUDING BUT NOT LIMITED TO ANY DEFENSE THEREOF), OR OTHER SIMILAR COSTS.
 *******************************************************************************/
//DOM-IGNORE-END

#ifndef _SYS_DEFINITIONS_H
#define _SYS_DEFINITIONS_H


// *****************************************************************************
// *****************************************************************************
// Section: Included Files
// *****************************************************************************
// *****************************************************************************

#include <stdint.h>
#include <stddef.h>
#include <stdbool.h>
#include "system/common/sys_common.h"
#include "system/common/sys_module.h"
#include "system/clk/sys_clk.h"
#include "system/clk/sys_clk_static.h"
#include "system/devcon/sys_devcon.h"
#include "system/console/sys_console.h"

#include "framework/driver/pmp/drv_pmp_static.h"
#include "driver/tmr/drv_tmr_static.h"
#include "peripheral/int/plib_int.h"
#include "system/ports/sys_ports.h"
#include "gfx/gfx.h"
#include "gfx/gfx_gol.h"
#include "gfx/gfx_gol_scheme.h"

#include "drv_gfx_INT043.h"     //INT035用
//#include "drv_gfx_INT035.h"     //INT035用
//#include "driver/gfx/controller/ssd1926/drv_gfx_ssd1926.h"
#include "system/debug/sys_debug.h"
#include "system/command/sys_command.h"


#include "gfx_hgc_definitions.h"
#include "app.h"


// *****************************************************************************
// *****************************************************************************
// Section: Type Definitions
// *****************************************************************************
// *****************************************************************************

// *****************************************************************************
/* System Objects

  Summary:
    Structure holding the system's object handles

  Description:
    This structure contains the object handles for all objects in the
    MPLAB Harmony project's system configuration.

  Remarks:
    These handles are returned from the "Initialize" functions for each module
    and must be passed into the "Tasks" function for each module.
*/

typedef struct
{
    SYS_MODULE_OBJ  sysDevcon;
    SYS_MODULE_OBJ  gfxObject0;
    
} SYSTEM_OBJECTS;


// *****************************************************************************
// *****************************************************************************
// Section: extern declarations
// *****************************************************************************
// *****************************************************************************

extern SYSTEM_OBJECTS sysObj;

#endif /* _SYS_DEFINITIONS_H */
/*******************************************************************************
 End of File
*/

 

<動作結果>

1. ピクチャー

 表示モード 液晶 INT043の画面
 画面@  
 画面A  
 画面B  


2.. 動画 ----> YouTube


■ マイクロチップ デモソフト”Primitive”  at PIC32MZ + INT070 

   
  <試作品仕様>
   ・ Harmonyのグラフィックライブラリのサンプルデモソフトとして マイクロチップから提供されている
      ”Primitive"(C:\microchip\harmony\v1_05\apps\gfx\primitive)を
     下記ハードウェアで実行する
      @ PIC: PIC32MZ2048EFH100
      A 液晶: (株)ディスプレーテック INT070A-TS WVGA、7.0インチ
   
   ・ 開発環境  Harmony ver.1.06、  XC32 ver.1.40、  MPLABX 3.06  PIC32MZ2048EFH  revison 1
  

  <試作品回路図>(→回路図のPDFファイル


<試作品外観>下記の写真には上記回路図にはない、また本テーマと関係のない部品が多々写っています



     

          

   <プログラム例>

//以下、main.c
//-------------------------------------------------------------------------------------------

/*******************************************************************************
  MPLAB Harmony Project Main Source File

  Company:
    Microchip Technology Inc.
  
  File Name:
    main.c

  Summary:
    This file contains the "main" function for an MPLAB Harmony project.

  Description:
    This file contains the "main" function for an MPLAB Harmony project.  The
    "main" function calls the "SYS_Initialize" function to initialize the state 
    machines of all MPLAB Harmony modules in the system and it calls the 
    "SYS_Tasks" function from within a system-wide "super" loop to maintain 
    their correct operation. These two functions are implemented in 
    configuration-specific files (usually "system_init.c" and "system_tasks.c")
    in a configuration-specific folder under the "src/system_config" folder 
    within this project's top-level folder.  An MPLAB Harmony project may have
    more than one configuration, each contained within it's own folder under
    the "system_config" folder.
 *******************************************************************************/

// DOM-IGNORE-BEGIN
/*******************************************************************************
Copyright (c) 2013-2014 released Microchip Technology Inc.  All rights reserved.

//Microchip licenses to you the right to use, modify, copy and distribute
Software only when embedded on a Microchip microcontroller or digital signal
controller that is integrated into your product or third party product
(pursuant to the sublicense terms in the accompanying license agreement).

You should refer to the license agreement accompanying this Software for
additional information regarding your rights and obligations.

SOFTWARE AND DOCUMENTATION ARE PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND,
EITHER EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION, ANY WARRANTY OF
MERCHANTABILITY, TITLE, NON-INFRINGEMENT AND FITNESS FOR A PARTICULAR PURPOSE.
IN NO EVENT SHALL MICROCHIP OR ITS LICENSORS BE LIABLE OR OBLIGATED UNDER
CONTRACT, NEGLIGENCE, STRICT LIABILITY, CONTRIBUTION, BREACH OF WARRANTY, OR
OTHER LEGAL EQUITABLE THEORY ANY DIRECT OR INDIRECT DAMAGES OR EXPENSES
INCLUDING BUT NOT LIMITED TO ANY INCIDENTAL, SPECIAL, INDIRECT, PUNITIVE OR
CONSEQUENTIAL DAMAGES, LOST PROFITS OR LOST DATA, COST OF PROCUREMENT OF
SUBSTITUTE GOODS, TECHNOLOGY, SERVICES, OR ANY CLAIMS BY THIRD PARTIES
(INCLUDING BUT NOT LIMITED TO ANY DEFENSE THEREOF), OR OTHER SIMILAR COSTS.
 *******************************************************************************/
// DOM-IGNORE-END


// *****************************************************************************
// *****************************************************************************
// Section: Included Files
// *****************************************************************************
// *****************************************************************************

#include <stddef.h>                     // Defines NULL
#include <stdbool.h>                    // Defines true
#include <stdlib.h>                     // Defines EXIT_FAILURE
#include "system/common/sys_module.h"   // SYS function prototypes


// *****************************************************************************
// *****************************************************************************
// Section: Main Entry Point
// *****************************************************************************
// *****************************************************************************

int main ( void )
{
    /* Initialize all MPLAB Harmony modules, including application(s). */
    SYS_Initialize ( NULL );


    while ( true )
    {
        /* Maintain state machines of all polled MPLAB Harmony modules. */
        SYS_Tasks ( );

    }

    /* Execution should not come here during normal operation */

    return ( EXIT_FAILURE );
}


/*******************************************************************************
 End of File
*/





//以下、app.c
//------------------------------------------------------------------------------------------------------

/*******************************************************************************
  MPLAB Harmony Application Source File
  
  Company:
    Microchip Technology Inc.
  
  File Name:
    app.c

  Summary:
    This file contains the source code for the MPLAB Harmony application.

  Description:
    This file contains the source code for the MPLAB Harmony application.  It 
    implements the logic of the application's state machine and it may call 
    API routines of other MPLAB Harmony modules in the system, such as drivers,
    system services, and middleware.  However, it does not call any of the
    system interfaces (such as the "Initialize" and "Tasks" functions) of any of
    the modules in the system or make any assumptions about when those functions
    are called.  That is the responsibility of the configuration-specific system
    files.
 *******************************************************************************/

// DOM-IGNORE-BEGIN
/*******************************************************************************
Copyright (c) 2013-2014 released Microchip Technology Inc.  All rights reserved.

Microchip licenses to you the right to use, modify, copy and distribute
Software only when embedded on a Microchip microcontroller or digital signal
controller that is integrated into your product or third party product
(pursuant to the sublicense terms in the accompanying license agreement).

You should refer to the license agreement accompanying this Software for
additional information regarding your rights and obligations.

SOFTWARE AND DOCUMENTATION ARE PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND,
EITHER EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION, ANY WARRANTY OF
MERCHANTABILITY, TITLE, NON-INFRINGEMENT AND FITNESS FOR A PARTICULAR PURPOSE.
IN NO EVENT SHALL MICROCHIP OR ITS LICENSORS BE LIABLE OR OBLIGATED UNDER
CONTRACT, NEGLIGENCE, STRICT LIABILITY, CONTRIBUTION, BREACH OF WARRANTY, OR
OTHER LEGAL EQUITABLE THEORY ANY DIRECT OR INDIRECT DAMAGES OR EXPENSES
INCLUDING BUT NOT LIMITED TO ANY INCIDENTAL, SPECIAL, INDIRECT, PUNITIVE OR
CONSEQUENTIAL DAMAGES, LOST PROFITS OR LOST DATA, COST OF PROCUREMENT OF
SUBSTITUTE GOODS, TECHNOLOGY, SERVICES, OR ANY CLAIMS BY THIRD PARTIES
(INCLUDING BUT NOT LIMITED TO ANY DEFENSE THEREOF), OR OTHER SIMILAR COSTS.
 *******************************************************************************/
// DOM-IGNORE-END


// *****************************************************************************
// *****************************************************************************
// Section: Included Files 
// *****************************************************************************
// *****************************************************************************

#include "app.h"
#include "1lcd_lib_C32.h"


int delay_Clock = 200000000;   //200MHz

void delay_us(volatile unsigned int usec)        //1μsec遅延
{
        volatile  int count;

        count = (int)(delay_Clock/20000000)*usec;


        do      //実測 at 200MH (Clock=200000000)
        {       //delay_us(1000):1000.4μsec  delay_us(100):100.6μsec  delay_us(10):10.5μsec  delay_us(1):1.5μsec
                asm("NOP"); asm("NOP"); asm("NOP"); asm("NOP"); asm("NOP");asm("NOP");
                asm("NOP"); asm("NOP"); asm("NOP"); asm("NOP"); asm("NOP"); asm("NOP");

                count--;
        }while(count != 0);


}

void delay_ms(volatile unsigned int msec)        //1msec遅延
{
        volatile unsigned int i;         //実測:at200MH (Clock=200000000)//delay_ms(1): 1.0006msec   delay_ms(100):100.04msec

        for(i=0; i<msec; i++)
        delay_us(1000);
}




// *****************************************************************************
// *****************************************************************************
// Section: Global Data Definitions
// *****************************************************************************
// *****************************************************************************

// *****************************************************************************
/* Application Data

  Summary:
    Holds application data

  Description:
    This structure holds the application's data.

  Remarks:
    This structure should be initialized by the APP_Initialize function.
    
    Application strings and buffers are be defined outside this structure.
*/

APP_DATA appData;





// *****************************************************************************
// *****************************************************************************
// Section: MACROS
// *****************************************************************************
// *****************************************************************************
#define MIN(x,y)                ((x > y)? y: x)
#define APP_SCREEN_DELAY_MS         (1000)
// *****************************************************************************
// *****************************************************************************
// Section: Global Variable Definitions
// *****************************************************************************
// *****************************************************************************

// *****************************************************************************
// *****************************************************************************
// Section: Application Local Routines
// *****************************************************************************
void APP_TMR_DelayMS ( unsigned int delayMs );


// *****************************************************************************
// *****************************************************************************
// Section: Application Callback Functions
// *****************************************************************************
// *****************************************************************************

/* TODO:  Add any necessary callback funtions.
*/

// *****************************************************************************
// *****************************************************************************
// Section: Application Local Functions
// *****************************************************************************
// *****************************************************************************

/* TODO:  Add any necessary local functions.
*/


// *****************************************************************************
// *****************************************************************************
// Section: Application Initialization and State Machine Functions
// *****************************************************************************
// *****************************************************************************

/*******************************************************************************
  Function:
    void APP_Initialize ( void )

  Remarks:
    See prototype in app.h.
 */

void APP_Initialize ( void )
{
    /* Place the App state machine in its initial state. */
    appData.state = APP_STATE_INIT;
    
    /* TODO: Initialize your application's state machine and other
     * parameters.
     */
}


/******************************************************************************
  Function:
    void APP_Tasks ( void )

  Remarks:
    See prototype in app.h.
 */

void APP_Tasks ( void )
{
    /* Check the application's current state. */
    switch ( appData.state )
    {
        /* Application's initial state. */
        case APP_STATE_INIT:
        {
            appData.state = APP_HGC_SCREEN1_DRAW;
            break;
        }
        
        case APP_HGC_SCREEN1_DRAW:
        {
            if(hgcObj.screenState != HGC_SCREEN_STATE_DISPLAY_SCREEN_screen1)
                return;
            
            GFX_HGC_ChangeScreen(screen2);
            APP_TMR_DelayMS(1000);
            appData.state = APP_HGC_SCREEN2_DRAW;
            break;
        }    

        case APP_HGC_SCREEN2_DRAW:
        {
            if(hgcObj.screenState != HGC_SCREEN_STATE_DISPLAY_SCREEN_screen2)
                return;
            
            GFX_HGC_ChangeScreen(screen3);
            APP_TMR_DelayMS(1000);
            appData.state = APP_HGC_SCREEN3_DRAW;
            break;
        }
        
        case APP_HGC_SCREEN3_DRAW:
        {
            if(hgcObj.screenState != HGC_SCREEN_STATE_DISPLAY_SCREEN_screen3)
                return;
            
            GFX_HGC_ChangeScreen(screen1);
            APP_TMR_DelayMS(1000);
            appData.state = APP_HGC_SCREEN1_DRAW;
            break;
        }    

        /* The default state should never be executed. */
        default:
        {
            /* TODO: Handle error in application's state machine. */
            break;
        }
    }
}

void APP_TMR_DelayMS ( unsigned int delayMs )
{
    if(delayMs)
    {
        uint32_t sysClk = SYS_CLK_FREQ;
        uint32_t t0;
        t0 = _CP0_GET_COUNT();
        while (_CP0_GET_COUNT() - t0 < (sysClk/2000)*delayMs);
    }
}

/*******************************************************************************
 End of File
 */







//以下、system_init.c
//------------------------------------------------------------------------------------



/*******************************************************************************
  System Initialization File

  File Name:
    system_init.c

  Summary:
    This file contains source code necessary to initialize the system.

  Description:
    This file contains source code necessary to initialize the system.  It
    implements the "SYS_Initialize" function, defines the configuration bits, 
    and allocates any necessary global system resources, such as the 
    sysObj structure that contains the object handles to all the MPLAB Harmony 
    module objects in the system.
 *******************************************************************************/

// DOM-IGNORE-BEGIN
/*******************************************************************************
Copyright (c) 2013-2015 released Microchip Technology Inc.  All rights reserved.

Microchip licenses to you the right to use, modify, copy and distribute
Software only when embedded on a Microchip microcontroller or digital signal
controller that is integrated into your product or third party product
(pursuant to the sublicense terms in the accompanying license agreement).

You should refer to the license agreement accompanying this Software for
additional information regarding your rights and obligations.

SOFTWARE AND DOCUMENTATION ARE PROVIDED AS IS WITHOUT WARRANTY OF ANY KIND,
EITHER EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION, ANY WARRANTY OF
MERCHANTABILITY, TITLE, NON-INFRINGEMENT AND FITNESS FOR A PARTICULAR PURPOSE.
IN NO EVENT SHALL MICROCHIP OR ITS LICENSORS BE LIABLE OR OBLIGATED UNDER
CONTRACT, NEGLIGENCE, STRICT LIABILITY, CONTRIBUTION, BREACH OF WARRANTY, OR
OTHER LEGAL EQUITABLE THEORY ANY DIRECT OR INDIRECT DAMAGES OR EXPENSES
INCLUDING BUT NOT LIMITED TO ANY INCIDENTAL, SPECIAL, INDIRECT, PUNITIVE OR
CONSEQUENTIAL DAMAGES, LOST PROFITS OR LOST DATA, COST OF PROCUREMENT OF
SUBSTITUTE GOODS, TECHNOLOGY, SERVICES, OR ANY CLAIMS BY THIRD PARTIES
(INCLUDING BUT NOT LIMITED TO ANY DEFENSE THEREOF), OR OTHER SIMILAR COSTS.
 *******************************************************************************/
// DOM-IGNORE-END


// *****************************************************************************
// *****************************************************************************
// Section: Included Files
// *****************************************************************************
// *****************************************************************************

#include "system_config.h"
#include "system_definitions.h"


// ****************************************************************************
// ****************************************************************************
// Section: Configuration Bits
// ****************************************************************************
// ****************************************************************************
// <editor-fold defaultstate="collapsed" desc="Configuration Bits">

/*** DEVCFG0 ***/

#pragma config DEBUG =      OFF
#pragma config JTAGEN =     OFF
#pragma config ICESEL =     ICS_PGx1
#pragma config TRCEN =      OFF
#pragma config BOOTISA =    MIPS32
#pragma config FECCCON =    OFF_UNLOCKED
#pragma config FSLEEP =     OFF
#pragma config DBGPER =     PG_ALL
#pragma config EJTAGBEN =   NORMAL
#pragma config CP =         OFF

/*** DEVCFG1 ***/

#pragma config FNOSC =      SPLL
#pragma config DMTINTV =    WIN_127_128
#pragma config FSOSCEN =    OFF
#pragma config IESO =       OFF
#pragma config POSCMOD =    EC
#pragma config OSCIOFNC =   OFF
#pragma config FCKSM =      CSECME
#pragma config WDTPS =      PS1048576
#pragma config WDTSPGM =    STOP
#pragma config FWDTEN =     OFF
#pragma config WINDIS =     NORMAL
#pragma config FWDTWINSZ =  WINSZ_25
#pragma config DMTCNT =     DMT31
#pragma config FDMTEN =     OFF

/*** DEVCFG2 ***/

#pragma config FPLLIDIV =   DIV_3
#pragma config FPLLRNG =    RANGE_5_10_MHZ

#pragma config FPLLICLK = PLL_FRC   //内蔵高速発振器選択    //★★★ バグ有 主発振回路選択の時、FPLLICLK = PLL_POSCではなくFPLLICLK = PLL_FRCを選択する。(at ver.1.33 XC32)
//#pragma config FPLLICLK =   PLL_POSC
#pragma config FPLLMULT =   MUL_50
#pragma config FPLLODIV =   DIV_2
#pragma config UPLLFSEL =   FREQ_24MHZ
//#pragma config UPLLEN =     ON

/*** DEVCFG3 ***/

#pragma config USERID =     0xffff
#pragma config FMIIEN =     ON
#pragma config FETHIO =     ON
#pragma config PGL1WAY =    ON
#pragma config PMDL1WAY =   ON
#pragma config IOL1WAY =    ON
#pragma config FUSBIDIO =   ON

/*** BF1SEQ0 ***/

#pragma config TSEQ =       0xffff
#pragma config CSEQ =       0xffff
// </editor-fold>


// *****************************************************************************
// *****************************************************************************
// Section: Library/Stack Initialization Data
// *****************************************************************************
// *****************************************************************************



// *****************************************************************************
// *****************************************************************************
// Section: Driver Initialization Data
// *****************************************************************************
// *****************************************************************************


// </editor-fold>

DRV_GFX_INIT drvGfxInit =
{
    .orientation             = DISP_ORIENTATION,
    .horizontalResolution    = DISP_HOR_RESOLUTION,
    .verticalResolution      = DISP_VER_RESOLUTION,
    
/*
    .dataWidth               = DISP_DATA_WIDTH,
    .horizontalPulseWidth    = DISP_HOR_PULSE_WIDTH,
    .horizontalBackPorch     = DISP_HOR_BACK_PORCH,
    .horizontalFrontPorch    = DISP_HOR_FRONT_PORCH,
    .verticalPulseWidth      = DISP_VER_PULSE_WIDTH,
    .verticalBackPorch       = DISP_VER_BACK_PORCH,
    .verticalFrontPorch      = DISP_VER_FRONT_PORCH,
    .logicShift              = DISP_INV_LSHIFT,
    .LCDType                 = 1,
    .colorType               = 0,
    .TCON_Init               = TCON_MODULE,
 */ 
    
};





// *****************************************************************************
// *****************************************************************************
// Section: System Data
// *****************************************************************************
// *****************************************************************************

/* Structure to hold the object handles for the modules in the system. */
SYSTEM_OBJECTS sysObj;


// *****************************************************************************
// *****************************************************************************
// Section: Module Initialization Data
// *****************************************************************************
// *****************************************************************************

/*** GFX Initialization Data ***/

 const GFX_INIT gfxInit0 =
{
    .drvInitialize    = NULL,
    
   
    .drvOpen          = DRV_GFX_INT070_Open,
    .drvInterfaceSet  = DRV_GFX_INT070_InterfaceSet, 
  //  .drvOpen          = DRV_GFX_SSD1926_Open,
  //  .drvInterfaceSet  = DRV_GFX_SSD1926_InterfaceSet,
};

/*******************************************************************************
  Device Control System Service Initialization Data
  
  <editor-fold defaultstate="collapsed" 
  desc="Device Control System Service Initialization Data">
*/

const SYS_DEVCON_INIT sysDevconInit =
{
    .moduleInit = {0},
};

// </editor-fold>


// *****************************************************************************
// *****************************************************************************
// Section: Static Initialization Functions
// *****************************************************************************
// *****************************************************************************


// *****************************************************************************
// *****************************************************************************
// Section: System Initialization
// *****************************************************************************
// *****************************************************************************




void ys_PMP_Initialize(void)
{

    short pClockPeriod = 1000000000 / 100000000;
    
    // PMP setup
    PMMODE = 0;
    PMAEN = 0;
    PMCON = 0;
    PMMODEbits.MODE = 2;                // Intel 8080 master interface

    #if (PMP_DATA_SETUP_TIME == 0)
        PMMODEbits.WAITB = 0;
    #else
        if (PMP_DATA_SETUP_TIME <= pClockPeriod)
            PMMODEbits.WAITB = 0;
        else if (PMP_DATA_SETUP_TIME > pClockPeriod)
            PMMODEbits.WAITB = (PMP_DATA_SETUP_TIME / pClockPeriod) + 1;
    #endif

    #if (PMP_DATA_WAIT_TIME == 0)
        PMMODEbits.WAITM = 0;
    #else
        if (PMP_DATA_WAIT_TIME <= pClockPeriod)
            PMMODEbits.WAITM = 1;
        else if (PMP_DATA_WAIT_TIME > pClockPeriod)
            PMMODEbits.WAITM = (PMP_DATA_WAIT_TIME / pClockPeriod) + 1;
    #endif

    #if (PMP_DATA_HOLD_TIME == 0)
        PMMODEbits.WAITE = 0;
    #else
        if (PMP_DATA_HOLD_TIME <= pClockPeriod)
            PMMODEbits.WAITE = 0;
        else if (PMP_DATA_HOLD_TIME > pClockPeriod)
            PMMODEbits.WAITE = (PMP_DATA_HOLD_TIME / pClockPeriod) + 1;
    #endif

    #if defined(USE_16BIT_PMP)
    PMMODEbits.MODE16 = 1;              // 16 bit mode
    #elif defined(USE_8BIT_PMP)
    PMMODEbits.MODE16 = 0;              // 8 bit mode
    #endif

    PMCONbits.PTRDEN = 1;               // enable RD line
    PMCONbits.PTWREN = 1;               // enable WR line
    PMCONbits.PMPEN = 1;                // enable PMP

    delay_us(200);



}






/*******************************************************************************
  Function:
    void SYS_Initialize ( SYS_INIT_DATA *data )

  Summary:
    Initializes the board, services, drivers, application and other modules.

  Remarks:
    See prototype in system/common/sys_module.h.
 */

void SYS_Initialize ( void* data )
{
    /* Core Processor Initialization */
    SYS_CLK_Initialize( NULL );
    sysObj.sysDevcon = SYS_DEVCON_Initialize(SYS_DEVCON_INDEX_0, (SYS_MODULE_INIT*)&sysDevconInit);
    SYS_DEVCON_PerformanceConfig(SYS_CLK_SystemFrequencyGet());
    SYS_PORTS_Initialize();

    /* Initialize Drivers */

    /* Initialize System Services */

      delay_ms(500);  

//PMP 初期化 Initialize PMP0
    ys_PMP_Initialize();
//    DRV_PMP0_Initialize();
//    DRV_PMP0_ModeConfig();

    
//GFX グラフィック初期化
    DRV_GFX_INT070_Initialize(GFX_INDEX_0, (SYS_MODULE_INIT*)&drvGfxInit);
    //DRV_GFX_SSD1926_Initialize(GFX_INDEX_0, (SYS_MODULE_INIT*)&drvGfxInit);
   

    /* Initialize Middleware */

    sysObj.gfxObject0 = GFX_Initialize(GFX_INDEX_0, (SYS_MODULE_INIT *)&gfxInit0);
           
    /* Initialize the Application */
    APP_Initialize();
}


/*******************************************************************************
 End of File
*/





//以下、system_config.h
//-------------------------------------------------------------------------------------------

/*******************************************************************************
  MPLAB Harmony System Configuration Header

  File Name:
    system_config.h

  Summary:
    Build-time configuration header for the system defined by this MPLAB Harmony
    project.

  Description:
    An MPLAB Project may have multiple configurations.  This file defines the
    build-time options for a single configuration.

  Remarks:
    This configuration header must not define any prototypes or data
    definitions (or include any files that do).  It only provides macro
    definitions for build-time configuration options that are not instantiated
    until used by another MPLAB Harmony module or application.
    
    Created with MPLAB Harmony Version 1.05
*******************************************************************************/

// DOM-IGNORE-BEGIN
/*******************************************************************************
Copyright (c) 2013-2015 released Microchip Technology Inc.  All rights reserved.

Microchip licenses to you the right to use, modify, copy and distribute
Software only when embedded on a Microchip microcontroller or digital signal
controller that is integrated into your product or third party product
(pursuant to the sublicense terms in the accompanying license agreement).

You should refer to the license agreement accompanying this Software for
additional information regarding your rights and obligations.

SOFTWARE AND DOCUMENTATION ARE PROVIDED AS IS WITHOUT WARRANTY OF ANY KIND,
EITHER EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION, ANY WARRANTY OF
MERCHANTABILITY, TITLE, NON-INFRINGEMENT AND FITNESS FOR A PARTICULAR PURPOSE.
IN NO EVENT SHALL MICROCHIP OR ITS LICENSORS BE LIABLE OR OBLIGATED UNDER
CONTRACT, NEGLIGENCE, STRICT LIABILITY, CONTRIBUTION, BREACH OF WARRANTY, OR
OTHER LEGAL EQUITABLE THEORY ANY DIRECT OR INDIRECT DAMAGES OR EXPENSES
INCLUDING BUT NOT LIMITED TO ANY INCIDENTAL, SPECIAL, INDIRECT, PUNITIVE OR
CONSEQUENTIAL DAMAGES, LOST PROFITS OR LOST DATA, COST OF PROCUREMENT OF
SUBSTITUTE GOODS, TECHNOLOGY, SERVICES, OR ANY CLAIMS BY THIRD PARTIES
(INCLUDING BUT NOT LIMITED TO ANY DEFENSE THEREOF), OR OTHER SIMILAR COSTS.
*******************************************************************************/
// DOM-IGNORE-END

#ifndef _SYSTEM_CONFIG_H
#define _SYSTEM_CONFIG_H

/* This is a temporary workaround for an issue with the peripheral library "Exists"
   functions that causes superfluous warnings.  It "nulls" out the definition of
   The PLIB function attribute that causes the warning.  Once that issue has been
   resolved, this definition should be removed. */
#define _PLIB_UNSUPPORTED


// *****************************************************************************
// *****************************************************************************
// Section: Included Files
// *****************************************************************************
// *****************************************************************************
/*  This section Includes other configuration headers necessary to completely
    define this configuration.
*/


// *****************************************************************************
// *****************************************************************************
// Section: System Service Configuration
// *****************************************************************************
// *****************************************************************************

// *****************************************************************************
/* Common System Service Configuration Options
*/
#define SYS_VERSION_STR           "1.05"
#define SYS_VERSION               10500

// *****************************************************************************
/* Clock System Service Configuration Options
*/
#define SYS_CLK_FREQ                        200000000ul
#define SYS_CLK_BUS_PERIPHERAL_1            100000000ul
#define SYS_CLK_BUS_PERIPHERAL_2            100000000ul
#define SYS_CLK_BUS_PERIPHERAL_3            100000000ul
#define SYS_CLK_BUS_PERIPHERAL_4            100000000ul
#define SYS_CLK_BUS_PERIPHERAL_5            100000000ul
#define SYS_CLK_BUS_PERIPHERAL_7            200000000ul
#define SYS_CLK_BUS_PERIPHERAL_8            100000000ul
#define SYS_CLK_CONFIG_PRIMARY_XTAL         24000000ul
#define SYS_CLK_CONFIG_SECONDARY_XTAL       0ul
   
/*** Ports System Service Configuration ***/
#define SYS_PORT_C_ANSEL        0xe01e
#define SYS_PORT_C_TRIS         0xf01e
#define SYS_PORT_C_LAT          0x0
#define SYS_PORT_C_ODC          0x0
#define SYS_PORT_C_CNPU         0x0
#define SYS_PORT_C_CNPD         0x0
#define SYS_PORT_C_CNEN         0x0

// *****************************************************************************
// *****************************************************************************
// Section: Driver Configuration
// *****************************************************************************
// *****************************************************************************

#define  GFX_USE_DISPLAY_CONTROLLER_INT035
 //#define  GFX_USE_DISPLAY_CONTROLLER_SSD1926

#define USE_16BIT_PMP
//#define USE_8BIT_PMP


// *****************************************************************************
// *****************************************************************************
// Section: Middleware & Other Library Configuration
// *****************************************************************************
// *****************************************************************************



/*** GFX Library Configuration ***/

#define GFX_INSTANCES_NUMBER                            1
#define GFX_SELF_PREEMPTION_LEVEL                       0
#define GFX_CONFIG_COLOR_DEPTH                          16

#define GFX_CONFIG_FONT_CHAR_SIZE                       8
#define GFX_CONFIG_FONT_EXTERNAL_DISABLE
#define GFX_CONFIG_FONT_RAM_DISABLE
#define GFX_CONFIG_IMAGE_EXTERNAL_DISABLE
#define GFX_CONFIG_IMAGE_RAM_DISABLE
#define GFX_CONFIG_GRADIENT_DISABLE
#define GFX_CONFIG_PALETTE_DISABLE
#define GFX_CONFIG_FONT_ANTIALIASED_DISABLE
#define GFX_CONFIG_TRANSPARENT_COLOR_DISABLE
#define GFX_CONFIG_PALETTE_EXTERNAL_DISABLE
#define GFX_CONFIG_DOUBLE_BUFFERING_DISABLE
#define GFX_CONFIG_USE_KEYBOARD_DISABLE
#define GFX_CONFIG_USE_TOUCHSCREEN_DISABLE
#define GFX_CONFIG_FOCUS_DISABLE
#define GFX_malloc(size)                                    malloc(size)
#define GFX_free(pObj)                                      free(pObj)


#endif // _SYSTEM_CONFIG_H
/*******************************************************************************
 End of File
*/




//以下、system_definition.h
//----------------------------------------------------------------------------------------
/*******************************************************************************
  System Definitions

  File Name:
    system_definitions.h

  Summary:
    MPLAB Harmony project system definitions.

  Description:
    This file contains the system-wide prototypes and definitions for an MPLAB
    Harmony project.
 *******************************************************************************/

//DOM-IGNORE-BEGIN
/*******************************************************************************
Copyright (c) 2013-2014 released Microchip Technology Inc.  All rights reserved.

Microchip licenses to you the right to use, modify, copy and distribute
Software only when embedded on a Microchip microcontroller or digital signal
controller that is integrated into your product or third party product
(pursuant to the sublicense terms in the accompanying license agreement).

You should refer to the license agreement accompanying this Software for
additional information regarding your rights and obligations.

SOFTWARE AND DOCUMENTATION ARE PROVIDED AS IS WITHOUT WARRANTY OF ANY KIND,
EITHER EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION, ANY WARRANTY OF
MERCHANTABILITY, TITLE, NON-INFRINGEMENT AND FITNESS FOR A PARTICULAR PURPOSE.
IN NO EVENT SHALL MICROCHIP OR ITS LICENSORS BE LIABLE OR OBLIGATED UNDER
CONTRACT, NEGLIGENCE, STRICT LIABILITY, CONTRIBUTION, BREACH OF WARRANTY, OR
OTHER LEGAL EQUITABLE THEORY ANY DIRECT OR INDIRECT DAMAGES OR EXPENSES
INCLUDING BUT NOT LIMITED TO ANY INCIDENTAL, SPECIAL, INDIRECT, PUNITIVE OR
CONSEQUENTIAL DAMAGES, LOST PROFITS OR LOST DATA, COST OF PROCUREMENT OF
SUBSTITUTE GOODS, TECHNOLOGY, SERVICES, OR ANY CLAIMS BY THIRD PARTIES
(INCLUDING BUT NOT LIMITED TO ANY DEFENSE THEREOF), OR OTHER SIMILAR COSTS.
 *******************************************************************************/
//DOM-IGNORE-END

#ifndef _SYS_DEFINITIONS_H
#define _SYS_DEFINITIONS_H


// *****************************************************************************
// *****************************************************************************
// Section: Included Files
// *****************************************************************************
// *****************************************************************************

#include <stdint.h>
#include <stddef.h>
#include <stdbool.h>
#include "system/common/sys_common.h"
#include "system/common/sys_module.h"
#include "system/clk/sys_clk.h"
#include "system/clk/sys_clk_static.h"
#include "system/devcon/sys_devcon.h"
#include "system/console/sys_console.h"

#include "framework/driver/pmp/drv_pmp_static.h"
#include "driver/tmr/drv_tmr_static.h"
#include "peripheral/int/plib_int.h"
#include "system/ports/sys_ports.h"
#include "gfx/gfx.h"
#include "gfx/gfx_gol.h"
#include "gfx/gfx_gol_scheme.h"


#include "drv_gfx_INT070.h"     //INT070用
//#include "driver/gfx/controller/ssd1926/drv_gfx_ssd1926.h"
#include "system/debug/sys_debug.h"
#include "system/command/sys_command.h"


#include "gfx_hgc_definitions.h"
#include "app.h"


// *****************************************************************************
// *****************************************************************************
// Section: Type Definitions
// *****************************************************************************
// *****************************************************************************

// *****************************************************************************
/* System Objects

  Summary:
    Structure holding the system's object handles

  Description:
    This structure contains the object handles for all objects in the
    MPLAB Harmony project's system configuration.

  Remarks:
    These handles are returned from the "Initialize" functions for each module
    and must be passed into the "Tasks" function for each module.
*/

typedef struct
{
    SYS_MODULE_OBJ  sysDevcon;
    SYS_MODULE_OBJ  gfxObject0;
    
} SYSTEM_OBJECTS;


// *****************************************************************************
// *****************************************************************************
// Section: extern declarations
// *****************************************************************************
// *****************************************************************************

extern SYSTEM_OBJECTS sysObj;

#endif /* _SYS_DEFINITIONS_H */
/*******************************************************************************
 End of File
*/





//以下、gfx_hgc_definitions.c
//-----------------------------------------------------------------------------------------------


/*******************************************************************************
  MPLAB Harmony Graphics Composer Generated Implementation File

  File Name:
    gfx_hgc_definitions.c

  Summary:
    Build-time generated implementation from the MPLAB Harmony
    Graphics Composer.

  Description:
    Build-time generated implementation from the MPLAB Harmony
    Graphics Composer.

    Created with MPLAB Harmony Version 1.05
*******************************************************************************/
// DOM-IGNORE-BEGIN
/*******************************************************************************
Copyright (c) 2013-2014 released Microchip Technology Inc.  All rights reserved.

Microchip licenses to you the right to use, modify, copy and distribute
Software only when embedded on a Microchip microcontroller or digital signal
controller that is integrated into your product or third party product
(pursuant to the sublicense terms in the accompanying license agreement).

You should refer to the license agreement accompanying this Software for
additional information regarding your rights and obligations.

SOFTWARE AND DOCUMENTATION ARE PROVIDED AS IS WITHOUT WARRANTY OF ANY KIND,
EITHER EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION, ANY WARRANTY OF
MERCHANTABILITY, TITLE, NON-INFRINGEMENT AND FITNESS FOR A PARTICULAR PURPOSE.
IN NO EVENT SHALL MICROCHIP OR ITS LICENSORS BE LIABLE OR OBLIGATED UNDER
CONTRACT, NEGLIGENCE, STRICT LIABILITY, CONTRIBUTION, BREACH OF WARRANTY, OR
OTHER LEGAL EQUITABLE THEORY ANY DIRECT OR INDIRECT DAMAGES OR EXPENSES
INCLUDING BUT NOT LIMITED TO ANY INCIDENTAL, SPECIAL, INDIRECT, PUNITIVE OR
CONSEQUENTIAL DAMAGES, LOST PROFITS OR LOST DATA, COST OF PROCUREMENT OF
SUBSTITUTE GOODS, TECHNOLOGY, SERVICES, OR ANY CLAIMS BY THIRD PARTIES
(INCLUDING BUT NOT LIMITED TO ANY DEFENSE THEREOF), OR OTHER SIMILAR COSTS.
*******************************************************************************/
// DOM-IGNORE-END

#include "gfx_hgc_definitions.h"

/*** Default GFX GOL Scheme ***/
#define GFX_SCHEMEDEFAULT GOLSchemeDefault
extern GFX_GOL_OBJ_SCHEME GFX_SCHEMEDEFAULT;

/*** HGC-specified GFX GOL Scheme ***/
static GFX_GOL_OBJ_SCHEME *gfxScheme0;

/*** Generated Asset References ***/
extern const GFX_RESOURCE_HDR flower16bit;
extern const GFX_RESOURCE_HDR fireflysung;

/*** Generated ASCII Text Labels ***/
static const GFX_XCHAR staticTextStr_0[] = { 0x31, 0x36, 0x62, 0x69, 0x74, 0x20, 0x42, 0x50, 0x50, 0x0 }; // 16bit BPP
/*** HGC Object Global ***/
HGC_OBJECTS hgcObj;
static HGC_STATES hgcState;

/******************************************************************************
  Function:
    HGC_SCREEN_STATES GFX_HGC_GetScreenState ( void )

  Remarks:
    This function returns the screen state
 */
HGC_SCREEN_STATES GFX_HGC_GetScreenState ( void )
{
    return hgcObj.screenState;
}


/******************************************************************************
  Function:
    void GFX_HGC_SetScreenState ( HGC_SCREEN_STATES newState )

  Remarks:
    This function sets the screen state machine to a new state
 */
void GFX_HGC_SetScreenState ( HGC_SCREEN_STATES newState )
{
    hgcObj.prevRefreshState = hgcObj.screenState;
    hgcObj.screenState = newState;
}


/******************************************************************************
  Function:
    void GFX_HGC_Setup ( void )

  Summary:
    This function sets up the GOL message callback and draw callbacks.  
 */
void GFX_HGC_Setup ( void )
{
    GFX_GOL_MessageCallbackSet(GFX_INDEX_0, &GFX_HGC_MessageCallback);
    GFX_GOL_DrawCallbackSet(GFX_INDEX_0, &GFX_HGC_DrawCallback);

    GFX_HGC_InitializeSchemes();

}

/******************************************************************************
  Function:
    void GFX_HGC_Tasks (SYS_MODULE_OBJ gfxObject);

  Summary:
    This function is called in SYS_Tasks.  The intent wait until the GFX library
    is initialized before supplying items to draw
*/
void GFX_HGC_Tasks  (SYS_MODULE_OBJ gfxObject)
{
    switch ( hgcState )
    {
        case HGC_STATE_INIT:
            if (GFX_Status(gfxObject)==SYS_STATUS_READY)
            {
                GFX_HGC_Setup();
                hgcState = HGC_STATE_RUNNING;
            }
            break;

        case HGC_STATE_RUNNING:
            break;

        default:
            break;
    }
}

/******************************************************************************
  Function:
    void GFX_HGC_SchemeCreate ( void )

  Summary:
    Allocates memory for a new scheme
 */
GFX_GOL_OBJ_SCHEME *GFX_HGC_SchemeCreate(void)
{
    GFX_GOL_OBJ_SCHEME  *pTemp;

    pTemp = (GFX_GOL_OBJ_SCHEME *)GFX_malloc(sizeof(GFX_GOL_OBJ_SCHEME));

    if(pTemp != NULL)
    {
        memcpy(pTemp, &GFX_SCHEMEDEFAULT, sizeof(GFX_GOL_OBJ_SCHEME));
    }

    return (pTemp);
}

/******************************************************************************
  Function:
    void GFX_HGC_InitializeSchemes ( void )

  Summary:
    Initializes all HGC-specified schemes
 */
void GFX_HGC_InitializeSchemes( void )
{
    gfxScheme0 = GFX_HGC_SchemeCreate();

#ifndef GFX_CONFIG_ALPHABLEND_DISABLE
    gfxScheme0->AlphaValue =        GFX_SCHEME_ALPHA_0;
#endif
    gfxScheme0->Color0 =            GFX_RGBConvert(GFX_SCHEME_PRIMARY_COLOR_RED_0, GFX_SCHEME_PRIMARY_COLOR_GREEN_0, GFX_SCHEME_PRIMARY_COLOR_BLUE_0);
    gfxScheme0->Color1 =            GFX_RGBConvert(GFX_SCHEME_SECONDARY_COLOR_RED_0, GFX_SCHEME_SECONDARY_COLOR_GREEN_0, GFX_SCHEME_SECONDARY_COLOR_BLUE_0);
    gfxScheme0->ColorDisabled =     GFX_RGBConvert(GFX_SCHEME_DISABLED_COLOR_RED_0, GFX_SCHEME_DISABLED_COLOR_GREEN_0, GFX_SCHEME_DISABLED_COLOR_BLUE_0);
    gfxScheme0->CommonBkColor =     GFX_RGBConvert(GFX_SCHEME_BACKGROUND_COLOR_RED_0, GFX_SCHEME_BACKGROUND_COLOR_GREEN_0, GFX_SCHEME_BACKGROUND_COLOR_BLUE_0);
        gfxScheme0->EmbossSize =        GFX_SCHEME_EMBOSS_SIZE_0;
    gfxScheme0->EmbossDkColor =     GFX_RGBConvert(GFX_SCHEME_EMBOSS_DARK_COLOR_RED_0, GFX_SCHEME_EMBOSS_DARK_COLOR_GREEN_0, GFX_SCHEME_EMBOSS_DARK_COLOR_BLUE_0);
    gfxScheme0->EmbossLtColor =     GFX_RGBConvert(GFX_SCHEME_EMBOSS_LIGHT_COLOR_RED_0, GFX_SCHEME_EMBOSS_LIGHT_COLOR_GREEN_0, GFX_SCHEME_EMBOSS_LIGHT_COLOR_BLUE_0);
        gfxScheme0->TextColor0 =        GFX_RGBConvert(GFX_SCHEME_TEXT_PRIMARY_COLOR_RED_0, GFX_SCHEME_TEXT_PRIMARY_COLOR_GREEN_0, GFX_SCHEME_TEXT_PRIMARY_COLOR_BLUE_0);
    gfxScheme0->TextColor1 =        GFX_RGBConvert(GFX_SCHEME_TEXT_SECONDARY_COLOR_RED_0, GFX_SCHEME_TEXT_SECONDARY_COLOR_GREEN_0, GFX_SCHEME_TEXT_SECONDARY_COLOR_BLUE_0);
    gfxScheme0->TextColorDisabled = GFX_RGBConvert(GFX_SCHEME_TEXT_DISABLED_COLOR_RED_0, GFX_SCHEME_TEXT_DISABLED_COLOR_GREEN_0, GFX_SCHEME_TEXT_DISABLED_COLOR_BLUE_0);
#ifndef GFX_CONFIG_GRADIENT_DISABLE
        gfxScheme0->gradientStartColor = GFX_RGBConvert(GFX_SCHEME_GRADIENT_START_COLOR_RED_0, GFX_SCHEME_GRADIENT_START_COLOR_GREEN_0, GFX_SCHEME_GRADIENT_START_COLOR_BLUE_0);
        gfxScheme0->gradientEndColor = GFX_RGBConvert(GFX_SCHEME_GRADIENT_END_COLOR_RED_0, GFX_SCHEME_GRADIENT_END_COLOR_GREEN_0, GFX_SCHEME_GRADIENT_END_COLOR_BLUE_0);
#endif
    gfxScheme0->CommonBkLeft =      GFX_SCHEME_BACKGROUND_OFFSET_TOP_0;
    gfxScheme0->CommonBkTop =       GFX_SCHEME_BACKGROUND_OFFSET_LEFT_0;
    gfxScheme0->pFont =             (GFX_RESOURCE_HDR*)&fireflysung;
    gfxScheme0->pCommonBkImage =    (GFX_RESOURCE_HDR*)NULL;
        
        gfxScheme0->fillStyle =         GFX_SCHEME_FILL_STYLE_0;
        gfxScheme0->CommonBkType =      GFX_SCHEME_BACKGROUND_TYPE_0;

}

/******************************************************************************
  Function: 
    bool GFX_HGC_MESSAGECallback(uint16_t objMsg, GFX_GOL_OBJ_HEADER* pObj, GFX_GOL_MESSAGE* pMsg)

  Input: 
    objMsg - translated message for the object,
    pObj - pointer to the object,
    pMsg - pointer to the non-translated, raw GOL message

  Output: 
    If the function returns non-zero the message will be processed by default

  Remarks: 
    GFX_GOL_MESSAGECallback() function calls it each time the valid message for the GOL object is received.
 */
bool GFX_HGC_MessageCallback(GFX_GOL_TRANSLATED_ACTION objMsg, GFX_GOL_OBJ_HEADER *pObj, GFX_GOL_MESSAGE *pMsg)
{
    // process messages for demo screens
    switch (hgcObj.screenState)
    {
        case HGC_SCREEN_STATE_DISPLAY_SCREEN_screen1:
            if (GFX_HGC_MsgPictures(objMsg, pObj) == true)
                return true;
            if (GFX_HGC_MsgStaticTexts(objMsg, pObj) == true)
                return true;
            break;
        case HGC_SCREEN_STATE_DISPLAY_SCREEN_screen2:
            if (GFX_HGC_MsgPictures(objMsg, pObj) == true)
                return true;
            if (GFX_HGC_MsgStaticTexts(objMsg, pObj) == true)
                return true;
            break;
        case HGC_SCREEN_STATE_DISPLAY_SCREEN_screen3:
            if (GFX_HGC_MsgPictures(objMsg, pObj) == true)
                return true;
            if (GFX_HGC_MsgStaticTexts(objMsg, pObj) == true)
                return true;
            break;
      default:
            // process message by default
            return true;
    }
    return true;
}

/******************************************************************************
  Function: 
    bool GFX_HGC_DrawCallback( void )

  Output: 
    If the function returns non-zero the draw control will be passed to GOL

  Remarks: 
    GFX_GOL_Draw() function calls it each time when GOL objects drawing is 
    completed. HGC-specified draw data is grouped by screens states. It takes 
    two states to complete the drawing of each screen.  GFX GOL objects are drawn
    first and then GFX Primitives are drawn next to ensure primitives are not
    covered by GOL objects.
 */
bool GFX_HGC_DrawCallback( void )
{
    switch (hgcObj.screenState)
    {
        case HGC_SCREEN_STATE_INIT:
            //Draw the primary screen as selected in the Composer
            GFX_HGC_SetScreenState(HGC_SCREEN_STATE_SETUP_SCREEN_screen1);
            return true;
        case HGC_SCREEN_STATE_SETUP_SCREEN_screen1:
            GFX_HGC_SetScreenState(HGC_SCREEN_STATE_PRE_DRAW_GOL_SCREEN_screen1);
            break;
        case HGC_SCREEN_STATE_PRE_DRAW_GOL_SCREEN_screen1:
            GFX_HGC_SetScreenState(HGC_SCREEN_STATE_DRAW_GOL_SCREEN_screen1);
            break;
        case HGC_SCREEN_STATE_DRAW_GOL_SCREEN_screen1:
            GFX_HGC_SetupScreen(screen1);
            GFX_HGC_DrawScreen_GOL(screen1);
            GFX_HGC_SetScreenState(HGC_SCREEN_STATE_POST_DRAW_GOL_SCREEN_screen1);
            break;
        case HGC_SCREEN_STATE_POST_DRAW_GOL_SCREEN_screen1:
            GFX_HGC_SetScreenState(HGC_SCREEN_STATE_PRE_DRAW_PRIMITIVE_SCREEN_screen1);
            break;
        case HGC_SCREEN_STATE_PRE_DRAW_PRIMITIVE_SCREEN_screen1:
            GFX_HGC_SetScreenState(HGC_SCREEN_STATE_DRAW_PRIMITIVE_SCREEN_screen1);
            break;
        case HGC_SCREEN_STATE_DRAW_PRIMITIVE_SCREEN_screen1:
            GFX_HGC_DrawScreen_Primitives(screen1);
            GFX_HGC_SetScreenState(HGC_SCREEN_STATE_POST_DRAW_PRIMITIVE_SCREEN_screen1);
            break;
        case HGC_SCREEN_STATE_POST_DRAW_PRIMITIVE_SCREEN_screen1:
            GFX_HGC_SetScreenState(HGC_SCREEN_STATE_DISPLAY_SCREEN_screen1);
            break;
        case HGC_SCREEN_STATE_DISPLAY_SCREEN_screen1:
            break;
        case HGC_SCREEN_STATE_SETUP_SCREEN_screen2:
            GFX_HGC_SetScreenState(HGC_SCREEN_STATE_PRE_DRAW_GOL_SCREEN_screen2);
            break;
        case HGC_SCREEN_STATE_PRE_DRAW_GOL_SCREEN_screen2:
            GFX_HGC_SetScreenState(HGC_SCREEN_STATE_DRAW_GOL_SCREEN_screen2);
            break;
        case HGC_SCREEN_STATE_DRAW_GOL_SCREEN_screen2:
            GFX_HGC_SetupScreen(screen2);
            GFX_HGC_DrawScreen_GOL(screen2);
            GFX_HGC_SetScreenState(HGC_SCREEN_STATE_POST_DRAW_GOL_SCREEN_screen2);
            break;
        case HGC_SCREEN_STATE_POST_DRAW_GOL_SCREEN_screen2:
            GFX_HGC_SetScreenState(HGC_SCREEN_STATE_PRE_DRAW_PRIMITIVE_SCREEN_screen2);
            break;
        case HGC_SCREEN_STATE_PRE_DRAW_PRIMITIVE_SCREEN_screen2:
            GFX_HGC_SetScreenState(HGC_SCREEN_STATE_DRAW_PRIMITIVE_SCREEN_screen2);
            break;
        case HGC_SCREEN_STATE_DRAW_PRIMITIVE_SCREEN_screen2:
            GFX_HGC_DrawScreen_Primitives(screen2);
            GFX_HGC_SetScreenState(HGC_SCREEN_STATE_POST_DRAW_PRIMITIVE_SCREEN_screen2);
            break;
        case HGC_SCREEN_STATE_POST_DRAW_PRIMITIVE_SCREEN_screen2:
            GFX_HGC_SetScreenState(HGC_SCREEN_STATE_DISPLAY_SCREEN_screen2);
            break;
        case HGC_SCREEN_STATE_DISPLAY_SCREEN_screen2:
            break;
        case HGC_SCREEN_STATE_SETUP_SCREEN_screen3:
            GFX_HGC_SetScreenState(HGC_SCREEN_STATE_PRE_DRAW_GOL_SCREEN_screen3);
            break;
        case HGC_SCREEN_STATE_PRE_DRAW_GOL_SCREEN_screen3:
            GFX_HGC_SetScreenState(HGC_SCREEN_STATE_DRAW_GOL_SCREEN_screen3);
            break;
        case HGC_SCREEN_STATE_DRAW_GOL_SCREEN_screen3:
            GFX_HGC_SetupScreen(screen3);
            GFX_HGC_DrawScreen_GOL(screen3);
            GFX_HGC_SetScreenState(HGC_SCREEN_STATE_POST_DRAW_GOL_SCREEN_screen3);
            break;
        case HGC_SCREEN_STATE_POST_DRAW_GOL_SCREEN_screen3:
            GFX_HGC_SetScreenState(HGC_SCREEN_STATE_PRE_DRAW_PRIMITIVE_SCREEN_screen3);
            break;
        case HGC_SCREEN_STATE_PRE_DRAW_PRIMITIVE_SCREEN_screen3:
            GFX_HGC_SetScreenState(HGC_SCREEN_STATE_DRAW_PRIMITIVE_SCREEN_screen3);
            break;
        case HGC_SCREEN_STATE_DRAW_PRIMITIVE_SCREEN_screen3:
            GFX_HGC_DrawScreen_Primitives(screen3);
            GFX_HGC_SetScreenState(HGC_SCREEN_STATE_POST_DRAW_PRIMITIVE_SCREEN_screen3);
            break;
        case HGC_SCREEN_STATE_POST_DRAW_PRIMITIVE_SCREEN_screen3:
            GFX_HGC_SetScreenState(HGC_SCREEN_STATE_DISPLAY_SCREEN_screen3);
            break;
        case HGC_SCREEN_STATE_DISPLAY_SCREEN_screen3:
            break;
        default:
            return true; // release drawing control to GOL by default
    }

    return true; // release drawing control to GOL
}

/******************************************************************************
  Function: 
    void GFX_HGC_SetupScreen( uint8_t  screenId )

  Remarks: 
    Clears current screen and starts a fresh screen with its background color
 */
void GFX_HGC_SetupScreen(uint8_t screenId)
{
    switch (screenId)
    {
        case screen1:
            GFX_ColorSet(GFX_INDEX_0, GFX_RGBConvert(0x00, 0x00, 0x00));
            GFX_ScreenClear(GFX_INDEX_0);

            GFX_GOL_ObjectListFree(GFX_INDEX_0); // free memory for the objects in the previous linked list and start new list
            break;
        case screen2:
            GFX_ColorSet(GFX_INDEX_0, GFX_RGBConvert(0x00, 0x00, 0x00));
            GFX_ScreenClear(GFX_INDEX_0);

            GFX_GOL_ObjectListFree(GFX_INDEX_0); // free memory for the objects in the previous linked list and start new list
            break;
        case screen3:
            GFX_ColorSet(GFX_INDEX_0, GFX_RGBConvert(0x00, 0x00, 0x00));
            GFX_ScreenClear(GFX_INDEX_0);

            GFX_GOL_ObjectListFree(GFX_INDEX_0); // free memory for the objects in the previous linked list and start new list
            break;
        default:
            break;
    }
}


/******************************************************************************
  Function: 
    bool GFX_HGC_ChangeScreen( uint8_t  screenId )

  Output: 
    Returns true if a screenId matches an existing screen identifier

  Remarks: 
    Can be called to initiate GFX Library to draw a new screen
 */
bool GFX_HGC_ChangeScreen(uint8_t screenId)
{
    switch (screenId)
    {
        case screen1:
            GFX_HGC_SetScreenState(HGC_SCREEN_STATE_SETUP_SCREEN_screen1);
            break;
        case screen2:
            GFX_HGC_SetScreenState(HGC_SCREEN_STATE_SETUP_SCREEN_screen2);
            break;
        case screen3:
            GFX_HGC_SetScreenState(HGC_SCREEN_STATE_SETUP_SCREEN_screen3);
            break;
        default:
            return false;
    }

    return true; // release drawing control to GOL
}

/******************************************************************************
  Function: 
    bool GFX_HGC_DrawScreen_GOL( uint8_t  screenId )

  Output: 
    Returns true if a screenId matches an existing screen identifier

  Remarks: 
    HGC-specified GFX GOL objects are drawn here, grouped by screen.
    The draw order is reverse Z-ordered.
 */
bool GFX_HGC_DrawScreen_GOL(uint8_t screenId)
{
    switch (screenId)
    {
        case screen1:
            break;
        case screen2:
            GFX_HGC_DrawItem(Picture1);
            GFX_HGC_DrawItem(StaticText1);
            break;
        case screen3:
            break;
        default:
            return false;
    }

    return true; // release drawing control to GOL
}


/******************************************************************************
  Function: 
    bool GFX_HGC_DrawScreen_Primitives( uint8_t  screenId )

  Output:
    Returns true if a screenId matches an existing screen identifier

  Remarks: 
    HGC-specified GFX Primitives are drawn here, grouped by screen.
    GFX Primitives are drawn after GFX GOL Objects to make sure GFX GOL Objects
    do not cover GFX Primitives
 */
bool GFX_HGC_DrawScreen_Primitives(uint8_t screenId)
{
    switch (screenId)
    {
        case screen1:
            GFX_HGC_DrawItem(Circle1);
            GFX_HGC_DrawItem(Circle2);
            GFX_HGC_DrawItem(Circle3);
            GFX_HGC_DrawItem(Circle4);
            GFX_HGC_DrawItem(Circle5);
            GFX_HGC_DrawItem(Circle6);
            GFX_HGC_DrawItem(Circle7);
            GFX_HGC_DrawItem(Circle8);
            GFX_HGC_DrawItem(Circle9);
            GFX_HGC_DrawItem(Circle10);
            GFX_HGC_DrawItem(Line1);
            GFX_HGC_DrawItem(Line2);
            GFX_HGC_DrawItem(Line3);
            GFX_HGC_DrawItem(Line4);
            GFX_HGC_DrawItem(Line5);
            GFX_HGC_DrawItem(Line6);
            GFX_HGC_DrawItem(Line7);
            GFX_HGC_DrawItem(Line8);
            GFX_HGC_DrawItem(Line9);
            GFX_HGC_DrawItem(Line10);
            GFX_HGC_DrawItem(Line11);
            break;
        case screen2:
            break;
        case screen3:
            GFX_HGC_DrawItem(Rectangle2);
            GFX_HGC_DrawItem(Rectangle3);
            GFX_HGC_DrawItem(Rectangle1);
            GFX_HGC_DrawItem(Rectangle4);
            GFX_HGC_DrawItem(Rectangle5);
            break;
        default:
            return true;
    }

    return true; // release drawing control to GOL
}


/******************************************************************************
  Function: 
    bool GFX_HGC_DrawItem(int itemId)

  Output:
    Returns true if a itemId matches an existing item identifier

  Remarks: 
    Every item specified in every screen in HGC is listed in this function
 */
bool GFX_HGC_DrawItem(int itemId)
{
    switch(itemId)
    {
    case StaticText1:
        hgcObj.pStaticText1Obj = GFX_GOL_StaticTextCreate
                (
                 GFX_INDEX_0,
                 StaticText1,      // button ID
                 GFX_STATICTEXT_LEFT_0,    // left
                 GFX_STATICTEXT_TOP_0,     // top
                 GFX_STATICTEXT_RIGHT_0,   // right
                 GFX_STATICTEXT_BOTTOM_0,  // bottom
                 GFX_STATICTEXT_STATE_0,   // state
                 (GFX_XCHAR*)staticTextStr_0,    // text
                 GFX_STATICTEXT_ALIGNMENT_0,       //alignment
                 GFX_STATICTEXT_SCHEME_0
                 ); // use alternate scheme
        break;
    case Picture1:
        hgcObj.pPicture1Obj = GFX_GOL_PictureControlCreate
                (
                 GFX_INDEX_0,
                 Picture1,      // picture ID
                 GFX_PICTURE_LEFT_0,    // left
                 GFX_PICTURE_TOP_0,     // top
                 GFX_PICTURE_RIGHT_0,   // right                                 
                 GFX_PICTURE_BOTTOM_0,  // bottom
                                 GFX_PICTURE_STATE_0,   // state                 
                 GFX_PICTURE_SCALE_0,     // scale
                 (GFX_RESOURCE_HDR*)&flower16bit,    // bitmap
                 GFX_PICTURE_SCHEME_0
                 );
        break;
                case Line11:
                {
                        GFX_ColorSet(GFX_INDEX_0, GFX_RGBConvert(0xF8, 0xFC, 0xF8));
                        GFX_LineStyleSet(GFX_INDEX_0, GFX_LINE_STYLE_THIN_SOLID);
                        GFX_LineDraw(GFX_INDEX_0,
                     267*800/320,  // p1x
                                                 0,  // p1y
                                                 53*800/320,  // p2x
                                                 479); // p2y
            /*
                                                 267,  // p1x
                                                 0,  // p1y
                                                 53,  // p2x
                                                 239); // p2y
             */ 
                        break;
                }               
                case Line10:
                {
                        GFX_ColorSet(GFX_INDEX_0, GFX_RGBConvert(0xF8, 0xFC, 0xF8));
                        GFX_LineStyleSet(GFX_INDEX_0, GFX_LINE_STYLE_THIN_SOLID);
                        GFX_LineDraw(GFX_INDEX_0,
                                                 214*800/320,  // p1x
                                                 0,  // p1y
                                                 106*800/320,  // p2x
                                                 479); // p2y
            
            /*
                                                 214,  // p1x
                                                 0,  // p1y
                                                 106,  // p2x
                                                 239); // p2y
             */
                        break;
                }               
                case Line9:
                {
                        GFX_ColorSet(GFX_INDEX_0, GFX_RGBConvert(0xF8, 0xFC, 0xF8));
                        GFX_LineStyleSet(GFX_INDEX_0, GFX_LINE_STYLE_THIN_SOLID);
                        GFX_LineDraw(GFX_INDEX_0,
                                                 106*800/320,  // p1x
                                                 0,  // p1y
                                                 214*800/320,  // p2x
                                                 479); // p2y
            
            /*            106,  // p1x
                                                 0,  // p1y
                                                 214,  // p2x
                                                 239); // p2y
             */ 
                        break;
                }               
                case Line8:
                {
                        GFX_ColorSet(GFX_INDEX_0, GFX_RGBConvert(0xF8, 0xFC, 0xF8));
                        GFX_LineStyleSet(GFX_INDEX_0, GFX_LINE_STYLE_THIN_SOLID);
                        GFX_LineDraw(GFX_INDEX_0,
                    
                                                 53*800/320,  // p1x
                                                 0,  // p1y
                                                 267*800/320,  // p2x
                                                 479); // p2y
            /*
                        53,  // p1x
                                                 0,  // p1y
                                                 267,  // p2x
                                                 239); // p2y
             */
                        break;
                }               
                case Line7:
                {
                        GFX_ColorSet(GFX_INDEX_0, GFX_RGBConvert(0xF8, 0xFC, 0xF8));
                        GFX_LineStyleSet(GFX_INDEX_0, GFX_LINE_STYLE_THIN_SOLID);
                        GFX_LineDraw(GFX_INDEX_0,
                                                 160*800/320,  // p1x
                                                 0,  // p1y
                                                 160*800/320,  // p2x
                                                 479); // p2y
            /*
                        160,  // p1x
                                                 0,  // p1y
                                                 160,  // p2x
                                                 239); // p2y
             */ 
                        break;
                }               
                case Line6:
                {
                        GFX_ColorSet(GFX_INDEX_0, GFX_RGBConvert(0xF8, 0xFC, 0xF8));
                        GFX_LineStyleSet(GFX_INDEX_0, GFX_LINE_STYLE_THIN_SOLID);
                        GFX_LineDraw(GFX_INDEX_0,
                                                 0,  // p1x
                                                 239*480/240,  // p1y
                                                 319*800/320,  // p2x
                                                 0); // p2y
            /*
                        0,  // p1x
                                                 239,  // p1y
                                                 319,  // p2x
                                                 0); // p2y
             */ 
                        break;
                }               
                case Line5:
                {
                        GFX_ColorSet(GFX_INDEX_0, GFX_RGBConvert(0xF8, 0xFC, 0xF8));
                        GFX_LineStyleSet(GFX_INDEX_0, GFX_LINE_STYLE_THIN_SOLID);
                        GFX_LineDraw(GFX_INDEX_0,
                                                 0,  // p1x
                                                 0,  // p1y
                                                 799,  // p2x
                                                 479); // p2y
            /*
                        0,  // p1x
                                                 0,  // p1y
                                                 319,  // p2x
                                                 239); // p2y
             */
                        break;
                }               
                case Line4: //黄緑  //右
                {
                        GFX_ColorSet(GFX_INDEX_0, GFX_RGBConvert(0x00, 0xFC, 0x00));
                        GFX_LineStyleSet(GFX_INDEX_0, GFX_LINE_STYLE_THIN_SOLID);
                        GFX_LineDraw(GFX_INDEX_0,
                    
                    
                                                 799,  // p1x
                                                 0,  // p1y
                                                 799,  // p2x
                                                 479); // p2y
           /*
                        319,  // p1x
                                                 0,  // p1y
                                                 319,  // p2x
                                                 239); // p2y
             */ 
                        break;
                }               
                case Line3:     //黄色  //左
                {
                        GFX_ColorSet(GFX_INDEX_0, GFX_RGBConvert(0xF8, 0xFC, 0x00));
                        GFX_LineStyleSet(GFX_INDEX_0, GFX_LINE_STYLE_THIN_SOLID);
                        GFX_LineDraw(GFX_INDEX_0,
                                                 0,  // p1x
                                                 0,  // p1y
                                                 0,  // p2x
                                                 479); // p2y
            /*
                        0,  // p1x
                                                 0,  // p1y
                                                 0,  // p2x
                                                 239); // p2y
             */
                        break;
                }               
                case Line2: //青    //下
                {
                        GFX_ColorSet(GFX_INDEX_0, GFX_RGBConvert(0x00, 0x00, 0xF8));
                        GFX_LineStyleSet(GFX_INDEX_0, GFX_LINE_STYLE_THIN_SOLID);
                        GFX_LineDraw(GFX_INDEX_0,
                     0,  // p1x
                                                 479,  // p1y
                                                 799,  // p2x
                                                 479); // p2y
            /*
                                                 0,  // p1x
                                                 239,  // p1y
                                                 319,  // p2x
                                                 239); // p2y
             */ 
                        break;
                }               
                case Line1: //赤 //上
                {
                        GFX_ColorSet(GFX_INDEX_0, GFX_RGBConvert(0xF8, 0x00, 0x00));
                        GFX_LineStyleSet(GFX_INDEX_0, GFX_LINE_STYLE_THIN_SOLID);
                        GFX_LineDraw(GFX_INDEX_0,
                    
                                                 0,  // p1x
                                                 0,  // p1y
                                                 799,  // p2x
                                                 0); // p2y
            /*
                        0,  // p1x
                                                 0,  // p1y
                                                 319,  // p2x
                                                 0); // p2y
          */   
                        break;
                }               
                case Rectangle5:
                {
                        GFX_ColorSet(GFX_INDEX_0, GFX_RGBConvert(0x00, 0x00, 0xF8));
                        GFX_LineStyleSet(GFX_INDEX_0, GFX_LINE_STYLE_THIN_SOLID);
                        GFX_RectangleDraw(GFX_INDEX_0,
                                                          65 + 240,  // p1x //240 = 800/2 - 320/2
                                                          30 + 120,  // p1y //120 = 480/2 - 240/2
                                                          255 + 240,  // p2x
                                                          210 + 120); // p2y
                        
                        break;
                }       
                case Rectangle4:
                {
                        GFX_ColorSet(GFX_INDEX_0, GFX_RGBConvert(0x00, 0x00, 0xF8));
                        GFX_LineStyleSet(GFX_INDEX_0, GFX_LINE_STYLE_THIN_SOLID);
                        GFX_RectangleDraw(GFX_INDEX_0,
                                                          80 +240,  // p1x
                                                          45 + 120,  // p1y
                                                          240 +240,  // p2x
                                                          195 + 120); // p2y
                        
                        break;
                }       
                case Rectangle1:
                {
                        GFX_FillStyleSet(GFX_INDEX_0, GFX_FILL_STYLE_ALPHA_COLOR);
                        GFX_ColorSet(GFX_INDEX_0, GFX_RGBConvert(0xF8, 0x00, 0x00));
                        GFX_AlphaBlendingValueSet(GFX_INDEX_0, 100);
                        GFX_RectangleFillDraw(GFX_INDEX_0,
                                                                  125 + 240,  // p1x
                                                                  90 + 120,  // p1y
                                                                  195 + 240,  // p2x
                                                                  150 + 120); // p2y
                        
                        GFX_ColorSet(GFX_INDEX_0, GFX_RGBConvert(0xF8, 0x00, 0x00));
                        GFX_LineStyleSet(GFX_INDEX_0, GFX_LINE_STYLE_THIN_SOLID);
                        GFX_RectangleDraw(GFX_INDEX_0,
                                                          125 + 240,  // p1x
                                                          90 + 120,  // p1y
                                                          195 + 240,  // p2x
                                                          150 + 120); // p2y
                        
                        break;
                }       
                case Rectangle3:
                {
                        GFX_FillStyleSet(GFX_INDEX_0, GFX_FILL_STYLE_COLOR);
                        GFX_ColorSet(GFX_INDEX_0, GFX_RGBConvert(0x00, 0xFC, 0x00));
                        GFX_RectangleFillDraw(GFX_INDEX_0,
                                                                  110 + 240,  // p1x
                                                                  75 + 120,  // p1y
                                                                  210 + 240,  // p2x
                                                                  165 + 120); // p2y
                        
                        GFX_ColorSet(GFX_INDEX_0, GFX_RGBConvert(0x00, 0xFC, 0x00));
                        GFX_LineStyleSet(GFX_INDEX_0, GFX_LINE_STYLE_THIN_SOLID);
                        GFX_RectangleDraw(GFX_INDEX_0,
                                                          110 + 240,  // p1x
                                                          75 + 120,  // p1y
                                                          210 + 240,  // p2x
                                                          165 + 120); // p2y
                        
                        break;
                }       
                case Rectangle2:
                {
                        GFX_FillStyleSet(GFX_INDEX_0, GFX_FILL_STYLE_COLOR);
                        GFX_ColorSet(GFX_INDEX_0, GFX_RGBConvert(0x00, 0x00, 0xF8));
                        GFX_RectangleFillDraw(GFX_INDEX_0,
                                                                  95 + 240,  // p1x
                                                                  60 + 120,  // p1y
                                                                  225 + 240,  // p2x
                                                                  180 + 120); // p2y
                        
                        GFX_ColorSet(GFX_INDEX_0, GFX_RGBConvert(0x00, 0x00, 0xF8));
                        GFX_LineStyleSet(GFX_INDEX_0, GFX_LINE_STYLE_THIN_SOLID);
                        GFX_RectangleDraw(GFX_INDEX_0,
                                                          95 + 240,  // p1x
                                                          60 + 120,  // p1y
                                                          225 + 240,  // p2x
                                                          180 + 120) ; // p2y
                        
                        break;
                }       
                case Circle10:
                {
                        GFX_ColorSet(GFX_INDEX_0,GFX_RGBConvert(0xF8, 0x00, 0x00));
                        GFX_LineStyleSet(GFX_INDEX_0, GFX_LINE_STYLE_THIN_SOLID);
                        GFX_CircleDraw(GFX_INDEX_0,
                                                   400, //160, // p1x
                                                   240, //120, // p1y
                                                   3); // radius
                                                   
                        break;
                }       
                case Circle9:
                {
                        GFX_ColorSet(GFX_INDEX_0,GFX_RGBConvert(0xF8, 0x00, 0x00));
                        GFX_LineStyleSet(GFX_INDEX_0, GFX_LINE_STYLE_THIN_SOLID);
                        GFX_CircleDraw(GFX_INDEX_0,
                                                   400, //160, // p1x
                                                   240, //120, // p1y
                                                   16); // radius
                                                   
                        break;
                }       
                case Circle8:
                {
                        GFX_ColorSet(GFX_INDEX_0,GFX_RGBConvert(0xF8, 0x00, 0x00));
                        GFX_LineStyleSet(GFX_INDEX_0, GFX_LINE_STYLE_THIN_SOLID);
                        GFX_CircleDraw(GFX_INDEX_0,
                                                   400, //160, // p1x
                                                   240, //120, // p1y
                                                   29); // radius
                                                   
                        break;
                }       
                case Circle7:
                {
                        GFX_ColorSet(GFX_INDEX_0,GFX_RGBConvert(0xF8, 0x00, 0x00));
                        GFX_LineStyleSet(GFX_INDEX_0, GFX_LINE_STYLE_THIN_SOLID);
                        GFX_CircleDraw(GFX_INDEX_0,
                                                   400, //160, // p1x
                                                   240, //120, // p1y
                                                   42); // radius
                                                   
                        break;
                }       
                case Circle6:
                {
                        GFX_ColorSet(GFX_INDEX_0,GFX_RGBConvert(0xF8, 0x00, 0x00));
                        GFX_LineStyleSet(GFX_INDEX_0, GFX_LINE_STYLE_THIN_SOLID);
                        GFX_CircleDraw(GFX_INDEX_0,
                                                     400, //160, // p1x
                                                   240, //120, // p1y
                                                   55); // radius
                                                   
                        break;
                }       
                case Circle5:
                {
                        GFX_ColorSet(GFX_INDEX_0,GFX_RGBConvert(0xF8, 0x00, 0x00));
                        GFX_LineStyleSet(GFX_INDEX_0, GFX_LINE_STYLE_THIN_SOLID);
                        GFX_CircleDraw(GFX_INDEX_0,
                                                   400, //160, // p1x
                                                   240, //120, // p1y
                                                   68); // radius
                                                   
                        break;
                }       
                case Circle4:
                {
                        GFX_ColorSet(GFX_INDEX_0,GFX_RGBConvert(0xF8, 0x00, 0x00));
                        GFX_LineStyleSet(GFX_INDEX_0, GFX_LINE_STYLE_THIN_SOLID);
                        GFX_CircleDraw(GFX_INDEX_0,
                                                   400, //160, // p1x
                                                   240, //120, // p1y
                                                   81); // radius
                                                   
                        break;
                }       
                case Circle3:
                {
                        GFX_ColorSet(GFX_INDEX_0,GFX_RGBConvert(0xF8, 0x00, 0x00));
                        GFX_LineStyleSet(GFX_INDEX_0, GFX_LINE_STYLE_THIN_SOLID);
                        GFX_CircleDraw(GFX_INDEX_0,
                                                   400, //160, // p1x
                                                   240, //120, // p1y
                                                   94); // radius
                                                   
                        break;
                }       
                case Circle2:
                {
                        GFX_ColorSet(GFX_INDEX_0,GFX_RGBConvert(0xF8, 0x00, 0x00));
                        GFX_LineStyleSet(GFX_INDEX_0, GFX_LINE_STYLE_THIN_SOLID);
                        GFX_CircleDraw(GFX_INDEX_0,
                                                   400, //160, // p1x
                                                   240, //120, // p1y
                                                   107); // radius
                                                   
                        break;
                }       
                case Circle1:
                {
                        GFX_ColorSet(GFX_INDEX_0,GFX_RGBConvert(0xF8, 0x00, 0x00));
                        GFX_LineStyleSet(GFX_INDEX_0, GFX_LINE_STYLE_THIN_SOLID);
                        GFX_CircleDraw(GFX_INDEX_0,
                                                   400, //160, // p1x
                                                   240, //120, // p1y
                                                   120); // radius
                                                   
                        break;
                }       
        default:
                return false; // process by default
    }

    return true;
}

/******************************************************************************
  Function: 
    bool GFX_HGC_MsgStaticTexts(uint16_t objMsg, GFX_GOL_OBJ_HEADER *pObj)

  Output:
    Returns true if a Object ID matches an existing item identifier

  Remarks: 
    Handles GFX GOL Static Text events
 */
bool GFX_HGC_MsgStaticTexts(uint16_t objMsg, GFX_GOL_OBJ_HEADER *pObj)
{
    switch (GFX_GOL_ObjectIDGet(pObj))
    {
        default:
            return false; // default false as it is not processed
    }    
}

/******************************************************************************
  Function: 
    bool GFX_HGC_MsgPictures(uint16_t objMsg, GFX_GOL_OBJ_HEADER *pObj)

  Output:
    Returns true if a Object ID matches an existing item identifier

  Remarks: 
    Handles GFX GOL Picture Control events
 */
bool GFX_HGC_MsgPictures(uint16_t objMsg, GFX_GOL_OBJ_HEADER *pObj)
{
    switch (GFX_GOL_ObjectIDGet(pObj))
    {
        default:
            return false; // default false as it is not processed
    }    
}





 <動作結果>

1. ピクチャー
  以下、各画面

  各画面   液晶INT070の画面
 画面@   
  画面A  
  画面B  


2. 動画 -----> YouTube


■ マイクロチップ デモソフト”Primitive”  at PIC32MZ + INT018 

   
  <試作品仕様>
   ・ Harmonyのグラフィックライブラリのサンプルデモソフトとして マイクロチップから提供されている
      ”Primitive"(C:\microchip\harmony\v1_05\apps\gfx\primitive)を
     下記ハードウェアで実行する
      @ PIC: PIC32MZ2048EFH100
      A 液晶: (株)ディスプレーテック INT018 1/16 VGA(160 x128)、1.8インチ
   
   ・ 開発環境  Harmony ver.1.06、  XC32 ver.1.40、  MPLABX 3.06  PIC32MZ2048EFH  revison 1
  

  <試作品回路図>(→回路図のPDFファイル



<試作品外観>下記の写真には上記回路図にはない、また本テーマと関係のない部品が多々写っています


          

   <プログラム例>

//以下、main.c
//--------------------------------------------------------------------------------------------
/*******************************************************************************
  MPLAB Harmony Project Main Source File

  Company:
    Microchip Technology Inc.
  
  File Name:
    main.c

  Summary:
    This file contains the "main" function for an MPLAB Harmony project.

  Description:
    This file contains the "main" function for an MPLAB Harmony project.  The
    "main" function calls the "SYS_Initialize" function to initialize the state 
    machines of all MPLAB Harmony modules in the system and it calls the 
    "SYS_Tasks" function from within a system-wide "super" loop to maintain 
    their correct operation. These two functions are implemented in 
    configuration-specific files (usually "system_init.c" and "system_tasks.c")
    in a configuration-specific folder under the "src/system_config" folder 
    within this project's top-level folder.  An MPLAB Harmony project may have
    more than one configuration, each contained within it's own folder under
    the "system_config" folder.
 *******************************************************************************/

// DOM-IGNORE-BEGIN
/*******************************************************************************
Copyright (c) 2013-2014 released Microchip Technology Inc.  All rights reserved.

//Microchip licenses to you the right to use, modify, copy and distribute
Software only when embedded on a Microchip microcontroller or digital signal
controller that is integrated into your product or third party product
(pursuant to the sublicense terms in the accompanying license agreement).

You should refer to the license agreement accompanying this Software for
additional information regarding your rights and obligations.

SOFTWARE AND DOCUMENTATION ARE PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND,
EITHER EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION, ANY WARRANTY OF
MERCHANTABILITY, TITLE, NON-INFRINGEMENT AND FITNESS FOR A PARTICULAR PURPOSE.
IN NO EVENT SHALL MICROCHIP OR ITS LICENSORS BE LIABLE OR OBLIGATED UNDER
CONTRACT, NEGLIGENCE, STRICT LIABILITY, CONTRIBUTION, BREACH OF WARRANTY, OR
OTHER LEGAL EQUITABLE THEORY ANY DIRECT OR INDIRECT DAMAGES OR EXPENSES
INCLUDING BUT NOT LIMITED TO ANY INCIDENTAL, SPECIAL, INDIRECT, PUNITIVE OR
CONSEQUENTIAL DAMAGES, LOST PROFITS OR LOST DATA, COST OF PROCUREMENT OF
SUBSTITUTE GOODS, TECHNOLOGY, SERVICES, OR ANY CLAIMS BY THIRD PARTIES
(INCLUDING BUT NOT LIMITED TO ANY DEFENSE THEREOF), OR OTHER SIMILAR COSTS.
 *******************************************************************************/
// DOM-IGNORE-END


// *****************************************************************************
// *****************************************************************************
// Section: Included Files
// *****************************************************************************
// *****************************************************************************

#include <stddef.h>                     // Defines NULL
#include <stdbool.h>                    // Defines true
#include <stdlib.h>                     // Defines EXIT_FAILURE
#include "system/common/sys_module.h"   // SYS function prototypes


// *****************************************************************************
// *****************************************************************************
// Section: Main Entry Point
// *****************************************************************************
// *****************************************************************************

int main ( void )
{
    /* Initialize all MPLAB Harmony modules, including application(s). */
    SYS_Initialize ( NULL );


    while ( true )
    {
        /* Maintain state machines of all polled MPLAB Harmony modules. */
        SYS_Tasks ( );

    }

    /* Execution should not come here during normal operation */

    return ( EXIT_FAILURE );
}


/*******************************************************************************
 End of File
*/




//以下、app.c
//---------------------------------------------------------------------------------------
/*******************************************************************************
  MPLAB Harmony Application Source File
  
  Company:
    Microchip Technology Inc.
  
  File Name:
    app.c

  Summary:
    This file contains the source code for the MPLAB Harmony application.

  Description:
    This file contains the source code for the MPLAB Harmony application.  It 
    implements the logic of the application's state machine and it may call 
    API routines of other MPLAB Harmony modules in the system, such as drivers,
    system services, and middleware.  However, it does not call any of the
    system interfaces (such as the "Initialize" and "Tasks" functions) of any of
    the modules in the system or make any assumptions about when those functions
    are called.  That is the responsibility of the configuration-specific system
    files.
 *******************************************************************************/

// DOM-IGNORE-BEGIN
/*******************************************************************************
Copyright (c) 2013-2014 released Microchip Technology Inc.  All rights reserved.

Microchip licenses to you the right to use, modify, copy and distribute
Software only when embedded on a Microchip microcontroller or digital signal
controller that is integrated into your product or third party product
(pursuant to the sublicense terms in the accompanying license agreement).

You should refer to the license agreement accompanying this Software for
additional information regarding your rights and obligations.

SOFTWARE AND DOCUMENTATION ARE PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND,
EITHER EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION, ANY WARRANTY OF
MERCHANTABILITY, TITLE, NON-INFRINGEMENT AND FITNESS FOR A PARTICULAR PURPOSE.
IN NO EVENT SHALL MICROCHIP OR ITS LICENSORS BE LIABLE OR OBLIGATED UNDER
CONTRACT, NEGLIGENCE, STRICT LIABILITY, CONTRIBUTION, BREACH OF WARRANTY, OR
OTHER LEGAL EQUITABLE THEORY ANY DIRECT OR INDIRECT DAMAGES OR EXPENSES
INCLUDING BUT NOT LIMITED TO ANY INCIDENTAL, SPECIAL, INDIRECT, PUNITIVE OR
CONSEQUENTIAL DAMAGES, LOST PROFITS OR LOST DATA, COST OF PROCUREMENT OF
SUBSTITUTE GOODS, TECHNOLOGY, SERVICES, OR ANY CLAIMS BY THIRD PARTIES
(INCLUDING BUT NOT LIMITED TO ANY DEFENSE THEREOF), OR OTHER SIMILAR COSTS.
 *******************************************************************************/
// DOM-IGNORE-END


// *****************************************************************************
// *****************************************************************************
// Section: Included Files 
// *****************************************************************************
// *****************************************************************************

#include "app.h"
#include "1lcd_lib_C32.h"


int delay_Clock = 200000000;   //200MHz

void delay_us(volatile unsigned int usec)        //1μsec遅延
{
        volatile  int count;

        count = (int)(delay_Clock/20000000)*usec;


        do      //実測 at 200MH (Clock=200000000)
        {       //delay_us(1000):1000.4μsec  delay_us(100):100.6μsec  delay_us(10):10.5μsec  delay_us(1):1.5μsec
                asm("NOP"); asm("NOP"); asm("NOP"); asm("NOP"); asm("NOP");asm("NOP");
                asm("NOP"); asm("NOP"); asm("NOP"); asm("NOP"); asm("NOP"); asm("NOP");

                count--;
        }while(count != 0);


}

void delay_ms(volatile unsigned int msec)        //1msec遅延
{
        volatile unsigned int i;         //実測:at200MH (Clock=200000000)//delay_ms(1): 1.0006msec   delay_ms(100):100.04msec

        for(i=0; i<msec; i++)
        delay_us(1000);
}




// *****************************************************************************
// *****************************************************************************
// Section: Global Data Definitions
// *****************************************************************************
// *****************************************************************************

// *****************************************************************************
/* Application Data

  Summary:
    Holds application data

  Description:
    This structure holds the application's data.

  Remarks:
    This structure should be initialized by the APP_Initialize function.
    
    Application strings and buffers are be defined outside this structure.
*/

APP_DATA appData;





// *****************************************************************************
// *****************************************************************************
// Section: MACROS
// *****************************************************************************
// *****************************************************************************
#define MIN(x,y)                ((x > y)? y: x)
#define APP_SCREEN_DELAY_MS         (1000)
// *****************************************************************************
// *****************************************************************************
// Section: Global Variable Definitions
// *****************************************************************************
// *****************************************************************************

// *****************************************************************************
// *****************************************************************************
// Section: Application Local Routines
// *****************************************************************************
void APP_TMR_DelayMS ( unsigned int delayMs );


// *****************************************************************************
// *****************************************************************************
// Section: Application Callback Functions
// *****************************************************************************
// *****************************************************************************

/* TODO:  Add any necessary callback funtions.
*/

// *****************************************************************************
// *****************************************************************************
// Section: Application Local Functions
// *****************************************************************************
// *****************************************************************************

/* TODO:  Add any necessary local functions.
*/


// *****************************************************************************
// *****************************************************************************
// Section: Application Initialization and State Machine Functions
// *****************************************************************************
// *****************************************************************************

/*******************************************************************************
  Function:
    void APP_Initialize ( void )

  Remarks:
    See prototype in app.h.
 */

void APP_Initialize ( void )
{
    /* Place the App state machine in its initial state. */
    appData.state = APP_STATE_INIT;
    
    /* TODO: Initialize your application's state machine and other
     * parameters.
     */
}


/******************************************************************************
  Function:
    void APP_Tasks ( void )

  Remarks:
    See prototype in app.h.
 */

void APP_Tasks ( void )
{
    /* Check the application's current state. */
    switch ( appData.state )
    {
        /* Application's initial state. */
        case APP_STATE_INIT:
        {
            appData.state = APP_HGC_SCREEN1_DRAW;
            break;
        }
        
        case APP_HGC_SCREEN1_DRAW:
        {
            if(hgcObj.screenState != HGC_SCREEN_STATE_DISPLAY_SCREEN_screen1)
                return;
            
            GFX_HGC_ChangeScreen(screen2);
            APP_TMR_DelayMS(1000);
            appData.state = APP_HGC_SCREEN2_DRAW;
            break;
        }    

        case APP_HGC_SCREEN2_DRAW:
        {
            if(hgcObj.screenState != HGC_SCREEN_STATE_DISPLAY_SCREEN_screen2)
                return;
            
            GFX_HGC_ChangeScreen(screen3);
            APP_TMR_DelayMS(1000);
            appData.state = APP_HGC_SCREEN3_DRAW;
            break;
        }
        
        case APP_HGC_SCREEN3_DRAW:
        {
            if(hgcObj.screenState != HGC_SCREEN_STATE_DISPLAY_SCREEN_screen3)
                return;
            
            GFX_HGC_ChangeScreen(screen1);
            APP_TMR_DelayMS(1000);
            appData.state = APP_HGC_SCREEN1_DRAW;
            break;
        }    

        /* The default state should never be executed. */
        default:
        {
            /* TODO: Handle error in application's state machine. */
            break;
        }
    }
}

void APP_TMR_DelayMS ( unsigned int delayMs )
{
    if(delayMs)
    {
        uint32_t sysClk = SYS_CLK_FREQ;
        uint32_t t0;
        t0 = _CP0_GET_COUNT();
        while (_CP0_GET_COUNT() - t0 < (sysClk/2000)*delayMs);
    }
}

/*******************************************************************************
 End of File
 */




//以下、system_init.c
//-----------------------------------------------------------------------
/*******************************************************************************
  System Initialization File

  File Name:
    system_init.c

  Summary:
    This file contains source code necessary to initialize the system.

  Description:
    This file contains source code necessary to initialize the system.  It
    implements the "SYS_Initialize" function, defines the configuration bits, 
    and allocates any necessary global system resources, such as the 
    sysObj structure that contains the object handles to all the MPLAB Harmony 
    module objects in the system.
 *******************************************************************************/

// DOM-IGNORE-BEGIN
/*******************************************************************************
Copyright (c) 2013-2015 released Microchip Technology Inc.  All rights reserved.

Microchip licenses to you the right to use, modify, copy and distribute
Software only when embedded on a Microchip microcontroller or digital signal
controller that is integrated into your product or third party product
(pursuant to the sublicense terms in the accompanying license agreement).

You should refer to the license agreement accompanying this Software for
additional information regarding your rights and obligations.

SOFTWARE AND DOCUMENTATION ARE PROVIDED AS IS WITHOUT WARRANTY OF ANY KIND,
EITHER EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION, ANY WARRANTY OF
MERCHANTABILITY, TITLE, NON-INFRINGEMENT AND FITNESS FOR A PARTICULAR PURPOSE.
IN NO EVENT SHALL MICROCHIP OR ITS LICENSORS BE LIABLE OR OBLIGATED UNDER
CONTRACT, NEGLIGENCE, STRICT LIABILITY, CONTRIBUTION, BREACH OF WARRANTY, OR
OTHER LEGAL EQUITABLE THEORY ANY DIRECT OR INDIRECT DAMAGES OR EXPENSES
INCLUDING BUT NOT LIMITED TO ANY INCIDENTAL, SPECIAL, INDIRECT, PUNITIVE OR
CONSEQUENTIAL DAMAGES, LOST PROFITS OR LOST DATA, COST OF PROCUREMENT OF
SUBSTITUTE GOODS, TECHNOLOGY, SERVICES, OR ANY CLAIMS BY THIRD PARTIES
(INCLUDING BUT NOT LIMITED TO ANY DEFENSE THEREOF), OR OTHER SIMILAR COSTS.
 *******************************************************************************/
// DOM-IGNORE-END


// *****************************************************************************
// *****************************************************************************
// Section: Included Files
// *****************************************************************************
// *****************************************************************************

#include "system_config.h"
#include "system_definitions.h"


// ****************************************************************************
// ****************************************************************************
// Section: Configuration Bits
// ****************************************************************************
// ****************************************************************************
// <editor-fold defaultstate="collapsed" desc="Configuration Bits">

/*** DEVCFG0 ***/

#pragma config DEBUG =      OFF
#pragma config JTAGEN =     OFF
#pragma config ICESEL =     ICS_PGx1
#pragma config TRCEN =      OFF
#pragma config BOOTISA =    MIPS32
#pragma config FECCCON =    OFF_UNLOCKED
#pragma config FSLEEP =     OFF
#pragma config DBGPER =     PG_ALL
#pragma config EJTAGBEN =   NORMAL
#pragma config CP =         OFF

/*** DEVCFG1 ***/

#pragma config FNOSC =      SPLL
#pragma config DMTINTV =    WIN_127_128
#pragma config FSOSCEN =    OFF
#pragma config IESO =       OFF
#pragma config POSCMOD =    EC
#pragma config OSCIOFNC =   OFF
#pragma config FCKSM =      CSECME
#pragma config WDTPS =      PS1048576
#pragma config WDTSPGM =    STOP
#pragma config FWDTEN =     OFF
#pragma config WINDIS =     NORMAL
#pragma config FWDTWINSZ =  WINSZ_25
#pragma config DMTCNT =     DMT31
#pragma config FDMTEN =     OFF

/*** DEVCFG2 ***/

#pragma config FPLLIDIV =   DIV_3
#pragma config FPLLRNG =    RANGE_5_10_MHZ

//#pragma config FPLLICLK = PLL_FRC   //内蔵高速発振器選択    //★★★ バグ有 主発振回路選択の時、FPLLICLK = PLL_POSCではなくFPLLICLK = PLL_FRCを選択する。(at ver.1.33 XC32)
#pragma config FPLLICLK =   PLL_POSC
#pragma config FPLLMULT =   MUL_50
#pragma config FPLLODIV =   DIV_2
#pragma config UPLLFSEL =   FREQ_24MHZ
//#pragma config UPLLEN =     ON

/*** DEVCFG3 ***/

#pragma config USERID =     0xffff
#pragma config FMIIEN =     ON
#pragma config FETHIO =     ON
#pragma config PGL1WAY =    ON
#pragma config PMDL1WAY =   ON
#pragma config IOL1WAY =    ON
#pragma config FUSBIDIO =   ON

/*** BF1SEQ0 ***/

#pragma config TSEQ =       0xffff
#pragma config CSEQ =       0xffff
// </editor-fold>


// *****************************************************************************
// *****************************************************************************
// Section: Library/Stack Initialization Data
// *****************************************************************************
// *****************************************************************************



// *****************************************************************************
// *****************************************************************************
// Section: Driver Initialization Data
// *****************************************************************************
// *****************************************************************************


// </editor-fold>

DRV_GFX_INIT drvGfxInit =
{
    .orientation             = DISP_ORIENTATION,
    .horizontalResolution    = DISP_HOR_RESOLUTION,
    .verticalResolution      = DISP_VER_RESOLUTION,
    
/*
    .dataWidth               = DISP_DATA_WIDTH,
    .horizontalPulseWidth    = DISP_HOR_PULSE_WIDTH,
    .horizontalBackPorch     = DISP_HOR_BACK_PORCH,
    .horizontalFrontPorch    = DISP_HOR_FRONT_PORCH,
    .verticalPulseWidth      = DISP_VER_PULSE_WIDTH,
    .verticalBackPorch       = DISP_VER_BACK_PORCH,
    .verticalFrontPorch      = DISP_VER_FRONT_PORCH,
    .logicShift              = DISP_INV_LSHIFT,
    .LCDType                 = 1,
    .colorType               = 0,
    .TCON_Init               = TCON_MODULE,
 */ 
    
};





// *****************************************************************************
// *****************************************************************************
// Section: System Data
// *****************************************************************************
// *****************************************************************************

/* Structure to hold the object handles for the modules in the system. */
SYSTEM_OBJECTS sysObj;


// *****************************************************************************
// *****************************************************************************
// Section: Module Initialization Data
// *****************************************************************************
// *****************************************************************************

/*** GFX Initialization Data ***/

 const GFX_INIT gfxInit0 =
{
    .drvInitialize    = NULL,
    
   
    .drvOpen          = DRV_GFX_INT018_Open,
    .drvInterfaceSet  = DRV_GFX_INT018_InterfaceSet, 
  //  .drvOpen          = DRV_GFX_SSD1926_Open,
  //  .drvInterfaceSet  = DRV_GFX_SSD1926_InterfaceSet,
};

/*******************************************************************************
  Device Control System Service Initialization Data
  
  <editor-fold defaultstate="collapsed" 
  desc="Device Control System Service Initialization Data">
*/

const SYS_DEVCON_INIT sysDevconInit =
{
    .moduleInit = {0},
};

// </editor-fold>


// *****************************************************************************
// *****************************************************************************
// Section: Static Initialization Functions
// *****************************************************************************
// *****************************************************************************


// *****************************************************************************
// *****************************************************************************
// Section: System Initialization
// *****************************************************************************
// *****************************************************************************




void ys_PMP_Initialize(void)
{

    short pClockPeriod = 1000000000 / 100000000;
    
    // PMP setup
    PMMODE = 0;
    PMAEN = 0;
    PMCON = 0;
    PMMODEbits.MODE = 2;                // Intel 8080 master interface

    #if (PMP_DATA_SETUP_TIME == 0)
        PMMODEbits.WAITB = 0;
    #else
        if (PMP_DATA_SETUP_TIME <= pClockPeriod)
            PMMODEbits.WAITB = 0;
        else if (PMP_DATA_SETUP_TIME > pClockPeriod)
            PMMODEbits.WAITB = (PMP_DATA_SETUP_TIME / pClockPeriod) + 1;
    #endif

    #if (PMP_DATA_WAIT_TIME == 0)
        PMMODEbits.WAITM = 0;
    #else
        if (PMP_DATA_WAIT_TIME <= pClockPeriod)
            PMMODEbits.WAITM = 1;
        else if (PMP_DATA_WAIT_TIME > pClockPeriod)
            PMMODEbits.WAITM = (PMP_DATA_WAIT_TIME / pClockPeriod) + 1;
    #endif

    #if (PMP_DATA_HOLD_TIME == 0)
        PMMODEbits.WAITE = 0;
    #else
        if (PMP_DATA_HOLD_TIME <= pClockPeriod)
            PMMODEbits.WAITE = 0;
        else if (PMP_DATA_HOLD_TIME > pClockPeriod)
            PMMODEbits.WAITE = (PMP_DATA_HOLD_TIME / pClockPeriod) + 1;
    #endif

    #if defined(USE_16BIT_PMP)
    PMMODEbits.MODE16 = 1;              // 16 bit mode
    #elif defined(USE_8BIT_PMP)
    PMMODEbits.MODE16 = 0;              // 8 bit mode
    #endif

    PMCONbits.PTRDEN = 1;               // enable RD line
    PMCONbits.PTWREN = 1;               // enable WR line
    PMCONbits.PMPEN = 1;                // enable PMP

    delay_us(200);



}






/*******************************************************************************
  Function:
    void SYS_Initialize ( SYS_INIT_DATA *data )

  Summary:
    Initializes the board, services, drivers, application and other modules.

  Remarks:
    See prototype in system/common/sys_module.h.
 */

void SYS_Initialize ( void* data )
{
    /* Core Processor Initialization */
    SYS_CLK_Initialize( NULL );
    sysObj.sysDevcon = SYS_DEVCON_Initialize(SYS_DEVCON_INDEX_0, (SYS_MODULE_INIT*)&sysDevconInit);
    SYS_DEVCON_PerformanceConfig(SYS_CLK_SystemFrequencyGet());
    
    delay_ms(1000); //SYS_PORTS_Initialize(); ys_PMP_Initialize(); の前に設定のこと
    
    
    SYS_PORTS_Initialize();
    
 /*    
   
    SYS_DEVCON_SystemUnlock();
    //PMP用ペリフェラルクロック低減 100MH → 25MHz
     PB2DIVbits.PBDIV = 0x03;  //PBCLK2 is SYSCLK divided by 4   //  PMP SPI 1/4 = 100MHz / 4 = 25MHz

    SYS_DEVCON_SystemLock();
    
*/
    /* Initialize Drivers */

    /* Initialize System Services */

      delay_ms(500);  

//PMP 初期化 Initialize PMP0
    ys_PMP_Initialize();
//    DRV_PMP0_Initialize();
//    DRV_PMP0_ModeConfig();

    
//GFX グラフィック初期化
    DRV_GFX_INT018_Initialize(GFX_INDEX_0, (SYS_MODULE_INIT*)&drvGfxInit);
    //DRV_GFX_SSD1926_Initialize(GFX_INDEX_0, (SYS_MODULE_INIT*)&drvGfxInit);
   

    /* Initialize Middleware */

    sysObj.gfxObject0 = GFX_Initialize(GFX_INDEX_0, (SYS_MODULE_INIT *)&gfxInit0);  //GFX初期化
           
    /* Initialize the Application */
    APP_Initialize();
}


/*******************************************************************************
 End of File
*/





//以下、system_config.h
//-----------------------------------------------------------------------------------------
/*******************************************************************************
  MPLAB Harmony System Configuration Header

  File Name:
    system_config.h

  Summary:
    Build-time configuration header for the system defined by this MPLAB Harmony
    project.

  Description:
    An MPLAB Project may have multiple configurations.  This file defines the
    build-time options for a single configuration.

  Remarks:
    This configuration header must not define any prototypes or data
    definitions (or include any files that do).  It only provides macro
    definitions for build-time configuration options that are not instantiated
    until used by another MPLAB Harmony module or application.
    
    Created with MPLAB Harmony Version 1.05
*******************************************************************************/

// DOM-IGNORE-BEGIN
/*******************************************************************************
Copyright (c) 2013-2015 released Microchip Technology Inc.  All rights reserved.

Microchip licenses to you the right to use, modify, copy and distribute
Software only when embedded on a Microchip microcontroller or digital signal
controller that is integrated into your product or third party product
(pursuant to the sublicense terms in the accompanying license agreement).

You should refer to the license agreement accompanying this Software for
additional information regarding your rights and obligations.

SOFTWARE AND DOCUMENTATION ARE PROVIDED AS IS WITHOUT WARRANTY OF ANY KIND,
EITHER EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION, ANY WARRANTY OF
MERCHANTABILITY, TITLE, NON-INFRINGEMENT AND FITNESS FOR A PARTICULAR PURPOSE.
IN NO EVENT SHALL MICROCHIP OR ITS LICENSORS BE LIABLE OR OBLIGATED UNDER
CONTRACT, NEGLIGENCE, STRICT LIABILITY, CONTRIBUTION, BREACH OF WARRANTY, OR
OTHER LEGAL EQUITABLE THEORY ANY DIRECT OR INDIRECT DAMAGES OR EXPENSES
INCLUDING BUT NOT LIMITED TO ANY INCIDENTAL, SPECIAL, INDIRECT, PUNITIVE OR
CONSEQUENTIAL DAMAGES, LOST PROFITS OR LOST DATA, COST OF PROCUREMENT OF
SUBSTITUTE GOODS, TECHNOLOGY, SERVICES, OR ANY CLAIMS BY THIRD PARTIES
(INCLUDING BUT NOT LIMITED TO ANY DEFENSE THEREOF), OR OTHER SIMILAR COSTS.
*******************************************************************************/
// DOM-IGNORE-END

#ifndef _SYSTEM_CONFIG_H
#define _SYSTEM_CONFIG_H

/* This is a temporary workaround for an issue with the peripheral library "Exists"
   functions that causes superfluous warnings.  It "nulls" out the definition of
   The PLIB function attribute that causes the warning.  Once that issue has been
   resolved, this definition should be removed. */
#define _PLIB_UNSUPPORTED


// *****************************************************************************
// *****************************************************************************
// Section: Included Files
// *****************************************************************************
// *****************************************************************************
/*  This section Includes other configuration headers necessary to completely
    define this configuration.
*/


// *****************************************************************************
// *****************************************************************************
// Section: System Service Configuration
// *****************************************************************************
// *****************************************************************************

// *****************************************************************************
/* Common System Service Configuration Options
*/
#define SYS_VERSION_STR           "1.05"
#define SYS_VERSION               10500

// *****************************************************************************
/* Clock System Service Configuration Options
*/
#define SYS_CLK_FREQ                        200000000ul
#define SYS_CLK_BUS_PERIPHERAL_1            100000000ul
#define SYS_CLK_BUS_PERIPHERAL_2            100000000ul
#define SYS_CLK_BUS_PERIPHERAL_3            100000000ul
#define SYS_CLK_BUS_PERIPHERAL_4            100000000ul
#define SYS_CLK_BUS_PERIPHERAL_5            100000000ul
#define SYS_CLK_BUS_PERIPHERAL_7            200000000ul
#define SYS_CLK_BUS_PERIPHERAL_8            100000000ul
#define SYS_CLK_CONFIG_PRIMARY_XTAL         24000000ul
#define SYS_CLK_CONFIG_SECONDARY_XTAL       0ul
   
/*** Ports System Service Configuration ***/
#define SYS_PORT_C_ANSEL        0xe01e
#define SYS_PORT_C_TRIS         0xf01e
#define SYS_PORT_C_LAT          0x0
#define SYS_PORT_C_ODC          0x0
#define SYS_PORT_C_CNPU         0x0
#define SYS_PORT_C_CNPD         0x0
#define SYS_PORT_C_CNEN         0x0

// *****************************************************************************
// *****************************************************************************
// Section: Driver Configuration
// *****************************************************************************
// *****************************************************************************

#define  GFX_USE_DISPLAY_CONTROLLER_INT028
 //#define  GFX_USE_DISPLAY_CONTROLLER_SSD1926

//#define USE_16BIT_PMP
#define USE_8BIT_PMP


// *****************************************************************************
// *****************************************************************************
// Section: Middleware & Other Library Configuration
// *****************************************************************************
// *****************************************************************************



/*** GFX Library Configuration ***/

#define GFX_INSTANCES_NUMBER                            1
#define GFX_SELF_PREEMPTION_LEVEL                       0
#define GFX_CONFIG_COLOR_DEPTH                          16

#define GFX_CONFIG_FONT_CHAR_SIZE                       8
#define GFX_CONFIG_FONT_EXTERNAL_DISABLE
#define GFX_CONFIG_FONT_RAM_DISABLE
#define GFX_CONFIG_IMAGE_EXTERNAL_DISABLE
#define GFX_CONFIG_IMAGE_RAM_DISABLE
#define GFX_CONFIG_GRADIENT_DISABLE
#define GFX_CONFIG_PALETTE_DISABLE
#define GFX_CONFIG_FONT_ANTIALIASED_DISABLE
#define GFX_CONFIG_TRANSPARENT_COLOR_DISABLE
#define GFX_CONFIG_PALETTE_EXTERNAL_DISABLE
#define GFX_CONFIG_DOUBLE_BUFFERING_DISABLE
#define GFX_CONFIG_USE_KEYBOARD_DISABLE
#define GFX_CONFIG_USE_TOUCHSCREEN_DISABLE
#define GFX_CONFIG_FOCUS_DISABLE
#define GFX_malloc(size)                                    malloc(size)
#define GFX_free(pObj)                                      free(pObj)


#endif // _SYSTEM_CONFIG_H
/*******************************************************************************
 End of File
*/




//以下、system_definition.h
//----------------------------------------------------------------------------------------
/*******************************************************************************
  System Definitions

  File Name:
    system_definitions.h

  Summary:
    MPLAB Harmony project system definitions.

  Description:
    This file contains the system-wide prototypes and definitions for an MPLAB
    Harmony project.
 *******************************************************************************/

//DOM-IGNORE-BEGIN
/*******************************************************************************
Copyright (c) 2013-2014 released Microchip Technology Inc.  All rights reserved.

Microchip licenses to you the right to use, modify, copy and distribute
Software only when embedded on a Microchip microcontroller or digital signal
controller that is integrated into your product or third party product
(pursuant to the sublicense terms in the accompanying license agreement).

You should refer to the license agreement accompanying this Software for
additional information regarding your rights and obligations.

SOFTWARE AND DOCUMENTATION ARE PROVIDED AS IS WITHOUT WARRANTY OF ANY KIND,
EITHER EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION, ANY WARRANTY OF
MERCHANTABILITY, TITLE, NON-INFRINGEMENT AND FITNESS FOR A PARTICULAR PURPOSE.
IN NO EVENT SHALL MICROCHIP OR ITS LICENSORS BE LIABLE OR OBLIGATED UNDER
CONTRACT, NEGLIGENCE, STRICT LIABILITY, CONTRIBUTION, BREACH OF WARRANTY, OR
OTHER LEGAL EQUITABLE THEORY ANY DIRECT OR INDIRECT DAMAGES OR EXPENSES
INCLUDING BUT NOT LIMITED TO ANY INCIDENTAL, SPECIAL, INDIRECT, PUNITIVE OR
CONSEQUENTIAL DAMAGES, LOST PROFITS OR LOST DATA, COST OF PROCUREMENT OF
SUBSTITUTE GOODS, TECHNOLOGY, SERVICES, OR ANY CLAIMS BY THIRD PARTIES
(INCLUDING BUT NOT LIMITED TO ANY DEFENSE THEREOF), OR OTHER SIMILAR COSTS.
 *******************************************************************************/
//DOM-IGNORE-END

#ifndef _SYS_DEFINITIONS_H
#define _SYS_DEFINITIONS_H


// *****************************************************************************
// *****************************************************************************
// Section: Included Files
// *****************************************************************************
// *****************************************************************************

#include <stdint.h>
#include <stddef.h>
#include <stdbool.h>
#include "system/common/sys_common.h"
#include "system/common/sys_module.h"
#include "system/clk/sys_clk.h"
#include "system/clk/sys_clk_static.h"
#include "system/devcon/sys_devcon.h"
#include "system/console/sys_console.h"

#include "framework/driver/pmp/drv_pmp_static.h"
#include "driver/tmr/drv_tmr_static.h"
#include "peripheral/int/plib_int.h"
#include "system/ports/sys_ports.h"
#include "gfx/gfx.h"
#include "gfx/gfx_gol.h"
#include "gfx/gfx_gol_scheme.h"


#include "drv_gfx_INT018.h"     //INT018用
//#include "driver/gfx/controller/ssd1926/drv_gfx_ssd1926.h"
#include "system/debug/sys_debug.h"
#include "system/command/sys_command.h"


#include "gfx_hgc_definitions.h"
#include "app.h"


// *****************************************************************************
// *****************************************************************************
// Section: Type Definitions
// *****************************************************************************
// *****************************************************************************

// *****************************************************************************
/* System Objects

  Summary:
    Structure holding the system's object handles

  Description:
    This structure contains the object handles for all objects in the
    MPLAB Harmony project's system configuration.

  Remarks:
    These handles are returned from the "Initialize" functions for each module
    and must be passed into the "Tasks" function for each module.
*/

typedef struct
{
    SYS_MODULE_OBJ  sysDevcon;
    SYS_MODULE_OBJ  gfxObject0;
    
} SYSTEM_OBJECTS;


// *****************************************************************************
// *****************************************************************************
// Section: extern declarations
// *****************************************************************************
// *****************************************************************************

extern SYSTEM_OBJECTS sysObj;

#endif /* _SYS_DEFINITIONS_H */
/*******************************************************************************
 End of File
*/




//以下、gfx_hgc_definitions.c
//---------------------------------------------------------
/*******************************************************************************
  MPLAB Harmony Graphics Composer Generated Implementation File

  File Name:
    gfx_hgc_definitions.c

  Summary:
    Build-time generated implementation from the MPLAB Harmony
    Graphics Composer.

  Description:
    Build-time generated implementation from the MPLAB Harmony
    Graphics Composer.

    Created with MPLAB Harmony Version 1.05
*******************************************************************************/
// DOM-IGNORE-BEGIN
/*******************************************************************************
Copyright (c) 2013-2014 released Microchip Technology Inc.  All rights reserved.

Microchip licenses to you the right to use, modify, copy and distribute
Software only when embedded on a Microchip microcontroller or digital signal
controller that is integrated into your product or third party product
(pursuant to the sublicense terms in the accompanying license agreement).

You should refer to the license agreement accompanying this Software for
additional information regarding your rights and obligations.

SOFTWARE AND DOCUMENTATION ARE PROVIDED AS IS WITHOUT WARRANTY OF ANY KIND,
EITHER EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION, ANY WARRANTY OF
MERCHANTABILITY, TITLE, NON-INFRINGEMENT AND FITNESS FOR A PARTICULAR PURPOSE.
IN NO EVENT SHALL MICROCHIP OR ITS LICENSORS BE LIABLE OR OBLIGATED UNDER
CONTRACT, NEGLIGENCE, STRICT LIABILITY, CONTRIBUTION, BREACH OF WARRANTY, OR
OTHER LEGAL EQUITABLE THEORY ANY DIRECT OR INDIRECT DAMAGES OR EXPENSES
INCLUDING BUT NOT LIMITED TO ANY INCIDENTAL, SPECIAL, INDIRECT, PUNITIVE OR
CONSEQUENTIAL DAMAGES, LOST PROFITS OR LOST DATA, COST OF PROCUREMENT OF
SUBSTITUTE GOODS, TECHNOLOGY, SERVICES, OR ANY CLAIMS BY THIRD PARTIES
(INCLUDING BUT NOT LIMITED TO ANY DEFENSE THEREOF), OR OTHER SIMILAR COSTS.
*******************************************************************************/
// DOM-IGNORE-END

#include "gfx_hgc_definitions.h"

/*** Default GFX GOL Scheme ***/
#define GFX_SCHEMEDEFAULT GOLSchemeDefault
extern GFX_GOL_OBJ_SCHEME GFX_SCHEMEDEFAULT;

/*** HGC-specified GFX GOL Scheme ***/
static GFX_GOL_OBJ_SCHEME *gfxScheme0;

/*** Generated Asset References ***/
extern const GFX_RESOURCE_HDR flower16bit;
extern const GFX_RESOURCE_HDR fireflysung;

/*** Generated ASCII Text Labels ***/
static const GFX_XCHAR staticTextStr_0[] = { 0x31, 0x36, 0x62, 0x69, 0x74, 0x20, 0x42, 0x50, 0x50, 0x0 }; // 16bit BPP
/*** HGC Object Global ***/
HGC_OBJECTS hgcObj;
static HGC_STATES hgcState;

/******************************************************************************
  Function:
    HGC_SCREEN_STATES GFX_HGC_GetScreenState ( void )

  Remarks:
    This function returns the screen state
 */
HGC_SCREEN_STATES GFX_HGC_GetScreenState ( void )
{
    return hgcObj.screenState;
}


/******************************************************************************
  Function:
    void GFX_HGC_SetScreenState ( HGC_SCREEN_STATES newState )

  Remarks:
    This function sets the screen state machine to a new state
 */
void GFX_HGC_SetScreenState ( HGC_SCREEN_STATES newState )
{
    hgcObj.prevRefreshState = hgcObj.screenState;
    hgcObj.screenState = newState;
}


/******************************************************************************
  Function:
    void GFX_HGC_Setup ( void )

  Summary:
    This function sets up the GOL message callback and draw callbacks.  
 */
void GFX_HGC_Setup ( void )
{
    GFX_GOL_MessageCallbackSet(GFX_INDEX_0, &GFX_HGC_MessageCallback);
    GFX_GOL_DrawCallbackSet(GFX_INDEX_0, &GFX_HGC_DrawCallback);

    GFX_HGC_InitializeSchemes();

}

/******************************************************************************
  Function:
    void GFX_HGC_Tasks (SYS_MODULE_OBJ gfxObject);

  Summary:
    This function is called in SYS_Tasks.  The intent wait until the GFX library
    is initialized before supplying items to draw
*/
void GFX_HGC_Tasks  (SYS_MODULE_OBJ gfxObject)
{
    switch ( hgcState )
    {
        case HGC_STATE_INIT:
            if (GFX_Status(gfxObject)==SYS_STATUS_READY)
            {
                GFX_HGC_Setup();
                hgcState = HGC_STATE_RUNNING;
            }
            break;

        case HGC_STATE_RUNNING:
            break;

        default:
            break;
    }
}

/******************************************************************************
  Function:
    void GFX_HGC_SchemeCreate ( void )

  Summary:
    Allocates memory for a new scheme
 */
GFX_GOL_OBJ_SCHEME *GFX_HGC_SchemeCreate(void)
{
    GFX_GOL_OBJ_SCHEME  *pTemp;

    pTemp = (GFX_GOL_OBJ_SCHEME *)GFX_malloc(sizeof(GFX_GOL_OBJ_SCHEME));

    if(pTemp != NULL)
    {
        memcpy(pTemp, &GFX_SCHEMEDEFAULT, sizeof(GFX_GOL_OBJ_SCHEME));
    }

    return (pTemp);
}

/******************************************************************************
  Function:
    void GFX_HGC_InitializeSchemes ( void )

  Summary:
    Initializes all HGC-specified schemes
 */
void GFX_HGC_InitializeSchemes( void )
{
    gfxScheme0 = GFX_HGC_SchemeCreate();

#ifndef GFX_CONFIG_ALPHABLEND_DISABLE
    gfxScheme0->AlphaValue =        GFX_SCHEME_ALPHA_0;
#endif
    gfxScheme0->Color0 =            GFX_RGBConvert(GFX_SCHEME_PRIMARY_COLOR_RED_0, GFX_SCHEME_PRIMARY_COLOR_GREEN_0, GFX_SCHEME_PRIMARY_COLOR_BLUE_0);
    gfxScheme0->Color1 =            GFX_RGBConvert(GFX_SCHEME_SECONDARY_COLOR_RED_0, GFX_SCHEME_SECONDARY_COLOR_GREEN_0, GFX_SCHEME_SECONDARY_COLOR_BLUE_0);
    gfxScheme0->ColorDisabled =     GFX_RGBConvert(GFX_SCHEME_DISABLED_COLOR_RED_0, GFX_SCHEME_DISABLED_COLOR_GREEN_0, GFX_SCHEME_DISABLED_COLOR_BLUE_0);
    gfxScheme0->CommonBkColor =     GFX_RGBConvert(GFX_SCHEME_BACKGROUND_COLOR_RED_0, GFX_SCHEME_BACKGROUND_COLOR_GREEN_0, GFX_SCHEME_BACKGROUND_COLOR_BLUE_0);
        gfxScheme0->EmbossSize =        GFX_SCHEME_EMBOSS_SIZE_0;
    gfxScheme0->EmbossDkColor =     GFX_RGBConvert(GFX_SCHEME_EMBOSS_DARK_COLOR_RED_0, GFX_SCHEME_EMBOSS_DARK_COLOR_GREEN_0, GFX_SCHEME_EMBOSS_DARK_COLOR_BLUE_0);
    gfxScheme0->EmbossLtColor =     GFX_RGBConvert(GFX_SCHEME_EMBOSS_LIGHT_COLOR_RED_0, GFX_SCHEME_EMBOSS_LIGHT_COLOR_GREEN_0, GFX_SCHEME_EMBOSS_LIGHT_COLOR_BLUE_0);
        gfxScheme0->TextColor0 =        GFX_RGBConvert(GFX_SCHEME_TEXT_PRIMARY_COLOR_RED_0, GFX_SCHEME_TEXT_PRIMARY_COLOR_GREEN_0, GFX_SCHEME_TEXT_PRIMARY_COLOR_BLUE_0);
    gfxScheme0->TextColor1 =        GFX_RGBConvert(GFX_SCHEME_TEXT_SECONDARY_COLOR_RED_0, GFX_SCHEME_TEXT_SECONDARY_COLOR_GREEN_0, GFX_SCHEME_TEXT_SECONDARY_COLOR_BLUE_0);
    gfxScheme0->TextColorDisabled = GFX_RGBConvert(GFX_SCHEME_TEXT_DISABLED_COLOR_RED_0, GFX_SCHEME_TEXT_DISABLED_COLOR_GREEN_0, GFX_SCHEME_TEXT_DISABLED_COLOR_BLUE_0);
#ifndef GFX_CONFIG_GRADIENT_DISABLE
        gfxScheme0->gradientStartColor = GFX_RGBConvert(GFX_SCHEME_GRADIENT_START_COLOR_RED_0, GFX_SCHEME_GRADIENT_START_COLOR_GREEN_0, GFX_SCHEME_GRADIENT_START_COLOR_BLUE_0);
        gfxScheme0->gradientEndColor = GFX_RGBConvert(GFX_SCHEME_GRADIENT_END_COLOR_RED_0, GFX_SCHEME_GRADIENT_END_COLOR_GREEN_0, GFX_SCHEME_GRADIENT_END_COLOR_BLUE_0);
#endif
    gfxScheme0->CommonBkLeft =      GFX_SCHEME_BACKGROUND_OFFSET_TOP_0;
    gfxScheme0->CommonBkTop =       GFX_SCHEME_BACKGROUND_OFFSET_LEFT_0;
    gfxScheme0->pFont =             (GFX_RESOURCE_HDR*)&fireflysung;
    gfxScheme0->pCommonBkImage =    (GFX_RESOURCE_HDR*)NULL;
        
        gfxScheme0->fillStyle =         GFX_SCHEME_FILL_STYLE_0;
        gfxScheme0->CommonBkType =      GFX_SCHEME_BACKGROUND_TYPE_0;

}

/******************************************************************************
  Function: 
    bool GFX_HGC_MESSAGECallback(uint16_t objMsg, GFX_GOL_OBJ_HEADER* pObj, GFX_GOL_MESSAGE* pMsg)

  Input: 
    objMsg - translated message for the object,
    pObj - pointer to the object,
    pMsg - pointer to the non-translated, raw GOL message

  Output: 
    If the function returns non-zero the message will be processed by default

  Remarks: 
    GFX_GOL_MESSAGECallback() function calls it each time the valid message for the GOL object is received.
 */
bool GFX_HGC_MessageCallback(GFX_GOL_TRANSLATED_ACTION objMsg, GFX_GOL_OBJ_HEADER *pObj, GFX_GOL_MESSAGE *pMsg)
{
    // process messages for demo screens
    switch (hgcObj.screenState)
    {
        case HGC_SCREEN_STATE_DISPLAY_SCREEN_screen1:
            if (GFX_HGC_MsgPictures(objMsg, pObj) == true)
                return true;
            if (GFX_HGC_MsgStaticTexts(objMsg, pObj) == true)
                return true;
            break;
        case HGC_SCREEN_STATE_DISPLAY_SCREEN_screen2:
            if (GFX_HGC_MsgPictures(objMsg, pObj) == true)
                return true;
            if (GFX_HGC_MsgStaticTexts(objMsg, pObj) == true)
                return true;
            break;
        case HGC_SCREEN_STATE_DISPLAY_SCREEN_screen3:
            if (GFX_HGC_MsgPictures(objMsg, pObj) == true)
                return true;
            if (GFX_HGC_MsgStaticTexts(objMsg, pObj) == true)
                return true;
            break;
      default:
            // process message by default
            return true;
    }
    return true;
}

/******************************************************************************
  Function: 
    bool GFX_HGC_DrawCallback( void )

  Output: 
    If the function returns non-zero the draw control will be passed to GOL

  Remarks: 
    GFX_GOL_Draw() function calls it each time when GOL objects drawing is 
    completed. HGC-specified draw data is grouped by screens states. It takes 
    two states to complete the drawing of each screen.  GFX GOL objects are drawn
    first and then GFX Primitives are drawn next to ensure primitives are not
    covered by GOL objects.
 */
bool GFX_HGC_DrawCallback( void )
{
    switch (hgcObj.screenState)
    {
        case HGC_SCREEN_STATE_INIT:
            //Draw the primary screen as selected in the Composer
            GFX_HGC_SetScreenState(HGC_SCREEN_STATE_SETUP_SCREEN_screen1);
            return true;
        case HGC_SCREEN_STATE_SETUP_SCREEN_screen1:
            GFX_HGC_SetScreenState(HGC_SCREEN_STATE_PRE_DRAW_GOL_SCREEN_screen1);
            break;
        case HGC_SCREEN_STATE_PRE_DRAW_GOL_SCREEN_screen1:
            GFX_HGC_SetScreenState(HGC_SCREEN_STATE_DRAW_GOL_SCREEN_screen1);
            break;
        case HGC_SCREEN_STATE_DRAW_GOL_SCREEN_screen1:
            GFX_HGC_SetupScreen(screen1);
            GFX_HGC_DrawScreen_GOL(screen1);
            GFX_HGC_SetScreenState(HGC_SCREEN_STATE_POST_DRAW_GOL_SCREEN_screen1);
            break;
        case HGC_SCREEN_STATE_POST_DRAW_GOL_SCREEN_screen1:
            GFX_HGC_SetScreenState(HGC_SCREEN_STATE_PRE_DRAW_PRIMITIVE_SCREEN_screen1);
            break;
        case HGC_SCREEN_STATE_PRE_DRAW_PRIMITIVE_SCREEN_screen1:
            GFX_HGC_SetScreenState(HGC_SCREEN_STATE_DRAW_PRIMITIVE_SCREEN_screen1);
            break;
        case HGC_SCREEN_STATE_DRAW_PRIMITIVE_SCREEN_screen1:
            GFX_HGC_DrawScreen_Primitives(screen1);
            GFX_HGC_SetScreenState(HGC_SCREEN_STATE_POST_DRAW_PRIMITIVE_SCREEN_screen1);
            break;
        case HGC_SCREEN_STATE_POST_DRAW_PRIMITIVE_SCREEN_screen1:
            GFX_HGC_SetScreenState(HGC_SCREEN_STATE_DISPLAY_SCREEN_screen1);
            break;
        case HGC_SCREEN_STATE_DISPLAY_SCREEN_screen1:
            break;
        case HGC_SCREEN_STATE_SETUP_SCREEN_screen2:
            GFX_HGC_SetScreenState(HGC_SCREEN_STATE_PRE_DRAW_GOL_SCREEN_screen2);
            break;
        case HGC_SCREEN_STATE_PRE_DRAW_GOL_SCREEN_screen2:
            GFX_HGC_SetScreenState(HGC_SCREEN_STATE_DRAW_GOL_SCREEN_screen2);
            break;
        case HGC_SCREEN_STATE_DRAW_GOL_SCREEN_screen2:
            GFX_HGC_SetupScreen(screen2);
            GFX_HGC_DrawScreen_GOL(screen2);
            GFX_HGC_SetScreenState(HGC_SCREEN_STATE_POST_DRAW_GOL_SCREEN_screen2);
            break;
        case HGC_SCREEN_STATE_POST_DRAW_GOL_SCREEN_screen2:
            GFX_HGC_SetScreenState(HGC_SCREEN_STATE_PRE_DRAW_PRIMITIVE_SCREEN_screen2);
            break;
        case HGC_SCREEN_STATE_PRE_DRAW_PRIMITIVE_SCREEN_screen2:
            GFX_HGC_SetScreenState(HGC_SCREEN_STATE_DRAW_PRIMITIVE_SCREEN_screen2);
            break;
        case HGC_SCREEN_STATE_DRAW_PRIMITIVE_SCREEN_screen2:
            GFX_HGC_DrawScreen_Primitives(screen2);
            GFX_HGC_SetScreenState(HGC_SCREEN_STATE_POST_DRAW_PRIMITIVE_SCREEN_screen2);
            break;
        case HGC_SCREEN_STATE_POST_DRAW_PRIMITIVE_SCREEN_screen2:
            GFX_HGC_SetScreenState(HGC_SCREEN_STATE_DISPLAY_SCREEN_screen2);
            break;
        case HGC_SCREEN_STATE_DISPLAY_SCREEN_screen2:
            break;
        case HGC_SCREEN_STATE_SETUP_SCREEN_screen3:
            GFX_HGC_SetScreenState(HGC_SCREEN_STATE_PRE_DRAW_GOL_SCREEN_screen3);
            break;
        case HGC_SCREEN_STATE_PRE_DRAW_GOL_SCREEN_screen3:
            GFX_HGC_SetScreenState(HGC_SCREEN_STATE_DRAW_GOL_SCREEN_screen3);
            break;
        case HGC_SCREEN_STATE_DRAW_GOL_SCREEN_screen3:
            GFX_HGC_SetupScreen(screen3);
            GFX_HGC_DrawScreen_GOL(screen3);
            GFX_HGC_SetScreenState(HGC_SCREEN_STATE_POST_DRAW_GOL_SCREEN_screen3);
            break;
        case HGC_SCREEN_STATE_POST_DRAW_GOL_SCREEN_screen3:
            GFX_HGC_SetScreenState(HGC_SCREEN_STATE_PRE_DRAW_PRIMITIVE_SCREEN_screen3);
            break;
        case HGC_SCREEN_STATE_PRE_DRAW_PRIMITIVE_SCREEN_screen3:
            GFX_HGC_SetScreenState(HGC_SCREEN_STATE_DRAW_PRIMITIVE_SCREEN_screen3);
            break;
        case HGC_SCREEN_STATE_DRAW_PRIMITIVE_SCREEN_screen3:
            GFX_HGC_DrawScreen_Primitives(screen3);
            GFX_HGC_SetScreenState(HGC_SCREEN_STATE_POST_DRAW_PRIMITIVE_SCREEN_screen3);
            break;
        case HGC_SCREEN_STATE_POST_DRAW_PRIMITIVE_SCREEN_screen3:
            GFX_HGC_SetScreenState(HGC_SCREEN_STATE_DISPLAY_SCREEN_screen3);
            break;
        case HGC_SCREEN_STATE_DISPLAY_SCREEN_screen3:
            break;
        default:
            return true; // release drawing control to GOL by default
    }

    return true; // release drawing control to GOL
}

/******************************************************************************
  Function: 
    void GFX_HGC_SetupScreen( uint8_t  screenId )

  Remarks: 
    Clears current screen and starts a fresh screen with its background color
 */
void GFX_HGC_SetupScreen(uint8_t screenId)
{
    switch (screenId)
    {
        case screen1:
            GFX_ColorSet(GFX_INDEX_0, GFX_RGBConvert(0x00, 0x00, 0x00));
            GFX_ScreenClear(GFX_INDEX_0);

            GFX_GOL_ObjectListFree(GFX_INDEX_0); // free memory for the objects in the previous linked list and start new list
            break;
        case screen2:
            GFX_ColorSet(GFX_INDEX_0, GFX_RGBConvert(0x00, 0x00, 0x00));
            GFX_ScreenClear(GFX_INDEX_0);

            GFX_GOL_ObjectListFree(GFX_INDEX_0); // free memory for the objects in the previous linked list and start new list
            break;
        case screen3:
            GFX_ColorSet(GFX_INDEX_0, GFX_RGBConvert(0x00, 0x00, 0x00));
            GFX_ScreenClear(GFX_INDEX_0);

            GFX_GOL_ObjectListFree(GFX_INDEX_0); // free memory for the objects in the previous linked list and start new list
            break;
        default:
            break;
    }
}


/******************************************************************************
  Function: 
    bool GFX_HGC_ChangeScreen( uint8_t  screenId )

  Output: 
    Returns true if a screenId matches an existing screen identifier

  Remarks: 
    Can be called to initiate GFX Library to draw a new screen
 */
bool GFX_HGC_ChangeScreen(uint8_t screenId)
{
    switch (screenId)
    {
        case screen1:
            GFX_HGC_SetScreenState(HGC_SCREEN_STATE_SETUP_SCREEN_screen1);
            break;
        case screen2:
            GFX_HGC_SetScreenState(HGC_SCREEN_STATE_SETUP_SCREEN_screen2);
            break;
        case screen3:
            GFX_HGC_SetScreenState(HGC_SCREEN_STATE_SETUP_SCREEN_screen3);
            break;
        default:
            return false;
    }

    return true; // release drawing control to GOL
}

/******************************************************************************
  Function: 
    bool GFX_HGC_DrawScreen_GOL( uint8_t  screenId )

  Output: 
    Returns true if a screenId matches an existing screen identifier

  Remarks: 
    HGC-specified GFX GOL objects are drawn here, grouped by screen.
    The draw order is reverse Z-ordered.
 */
bool GFX_HGC_DrawScreen_GOL(uint8_t screenId)
{
    switch (screenId)
    {
        case screen1:
            break;
        case screen2:
            GFX_HGC_DrawItem(Picture1);
            GFX_HGC_DrawItem(StaticText1);
            break;
        case screen3:
            break;
        default:
            return false;
    }

    return true; // release drawing control to GOL
}


/******************************************************************************
  Function: 
    bool GFX_HGC_DrawScreen_Primitives( uint8_t  screenId )

  Output:
    Returns true if a screenId matches an existing screen identifier

  Remarks: 
    HGC-specified GFX Primitives are drawn here, grouped by screen.
    GFX Primitives are drawn after GFX GOL Objects to make sure GFX GOL Objects
    do not cover GFX Primitives
 */
bool GFX_HGC_DrawScreen_Primitives(uint8_t screenId)
{
    switch (screenId)
    {
        case screen1:
            GFX_HGC_DrawItem(Circle1);
            GFX_HGC_DrawItem(Circle2);
            GFX_HGC_DrawItem(Circle3);
            GFX_HGC_DrawItem(Circle4);
            GFX_HGC_DrawItem(Circle5);
            GFX_HGC_DrawItem(Circle6);
            GFX_HGC_DrawItem(Circle7);
            GFX_HGC_DrawItem(Circle8);
            GFX_HGC_DrawItem(Circle9);
            GFX_HGC_DrawItem(Circle10);
            GFX_HGC_DrawItem(Line1);
            GFX_HGC_DrawItem(Line2);
            GFX_HGC_DrawItem(Line3);
            GFX_HGC_DrawItem(Line4);
            GFX_HGC_DrawItem(Line5);
            GFX_HGC_DrawItem(Line6);
            GFX_HGC_DrawItem(Line7);
            GFX_HGC_DrawItem(Line8);
            GFX_HGC_DrawItem(Line9);
            GFX_HGC_DrawItem(Line10);
            GFX_HGC_DrawItem(Line11);
            break;
        case screen2:
            break;
        case screen3:
            GFX_HGC_DrawItem(Rectangle2);
            GFX_HGC_DrawItem(Rectangle3);
            GFX_HGC_DrawItem(Rectangle1);
            GFX_HGC_DrawItem(Rectangle4);
            GFX_HGC_DrawItem(Rectangle5);
            break;
        default:
            return true;
    }

    return true; // release drawing control to GOL
}


/******************************************************************************
  Function: 
    bool GFX_HGC_DrawItem(int itemId)

  Output:
    Returns true if a itemId matches an existing item identifier

  Remarks: 
    Every item specified in every screen in HGC is listed in this function
 */
bool GFX_HGC_DrawItem(int itemId)
{
    switch(itemId)
    {
    case StaticText1:
        hgcObj.pStaticText1Obj = GFX_GOL_StaticTextCreate
                (
                 GFX_INDEX_0,
                 StaticText1,      // button ID
                 GFX_STATICTEXT_LEFT_0,    // left
                 GFX_STATICTEXT_TOP_0,     // top
                 GFX_STATICTEXT_RIGHT_0,   // right
                 GFX_STATICTEXT_BOTTOM_0,  // bottom
                 GFX_STATICTEXT_STATE_0,   // state
                 (GFX_XCHAR*)staticTextStr_0,    // text
                 GFX_STATICTEXT_ALIGNMENT_0,       //alignment
                 GFX_STATICTEXT_SCHEME_0
                 ); // use alternate scheme
        break;
    case Picture1:
        hgcObj.pPicture1Obj = GFX_GOL_PictureControlCreate
                (
                 GFX_INDEX_0,
                 Picture1,      // picture ID
                 GFX_PICTURE_LEFT_0,    // left
                 GFX_PICTURE_TOP_0,     // top
                 GFX_PICTURE_RIGHT_0,   // right                                 
                 GFX_PICTURE_BOTTOM_0,  // bottom
                                 GFX_PICTURE_STATE_0,   // state                 
                 GFX_PICTURE_SCALE_0,     // scale
                 (GFX_RESOURCE_HDR*)&flower16bit,    // bitmap
                 GFX_PICTURE_SCHEME_0
                 );
        break;
                case Line11:
                {
                        GFX_ColorSet(GFX_INDEX_0, GFX_RGBConvert(0xF8, 0xFC, 0xF8));
                        GFX_LineStyleSet(GFX_INDEX_0, GFX_LINE_STYLE_THIN_SOLID);
                        GFX_LineDraw(GFX_INDEX_0,
                                                 160/6*5,   //240/6*5,   //267,  // p1x
                                                 0,  // p1y
                                                 160/6, //240/6, //53,  // p2x
                                                 127);  //319);  //239); // p2y
                        break;
                }               
                case Line10:
                {
                        GFX_ColorSet(GFX_INDEX_0, GFX_RGBConvert(0xF8, 0xFC, 0xF8));
                        GFX_LineStyleSet(GFX_INDEX_0, GFX_LINE_STYLE_THIN_SOLID);
                        GFX_LineDraw(GFX_INDEX_0,
                                                 160/6*4,   //240/6*4,   //214,  // p1x
                                                 0,  // p1y
                                                 160/6*2,   //240/6*2,   //106,  // p2x
                                                 127);  //319);  //239); // p2y
                        break;
                }               
                case Line9:
                {
                        GFX_ColorSet(GFX_INDEX_0, GFX_RGBConvert(0xF8, 0xFC, 0xF8));
                        GFX_LineStyleSet(GFX_INDEX_0, GFX_LINE_STYLE_THIN_SOLID);
                        GFX_LineDraw(GFX_INDEX_0,
                                                 160/6*2,   //240/6*2,   //106,  // p1x
                                                 0,  // p1y
                                                 160/6*4,   //240/6*4,   //214,  // p2x
                                                 127);  //319);  //239); // p2y
                        break;
                }               
                case Line8:
                {
                        GFX_ColorSet(GFX_INDEX_0, GFX_RGBConvert(0xF8, 0xFC, 0xF8));
                        GFX_LineStyleSet(GFX_INDEX_0, GFX_LINE_STYLE_THIN_SOLID);
                        GFX_LineDraw(GFX_INDEX_0,
                                                 160/6, //240/6, //53,  // p1x
                                                 0,  // p1y
                                                 160/6*5,   //240/6*5,   //267,  // p2x
                                                 127);   //319);  //239); // p2y
                        break;
                }               
                case Line7:
                {
                        GFX_ColorSet(GFX_INDEX_0, GFX_RGBConvert(0xF8, 0xFC, 0xF8));
                        GFX_LineStyleSet(GFX_INDEX_0, GFX_LINE_STYLE_THIN_SOLID);
                        GFX_LineDraw(GFX_INDEX_0,
                                                160/2,    // 160,  // p1x
                                                 0,  // p1y
                                                160/2,    // 160,  // p2x
                                                127);    // 239); // p2y
                        break;
                }               
                case Line6:
                {
                        GFX_ColorSet(GFX_INDEX_0, GFX_RGBConvert(0xF8, 0xFC, 0xF8));
                        GFX_LineStyleSet(GFX_INDEX_0, GFX_LINE_STYLE_THIN_SOLID);
                        GFX_LineDraw(GFX_INDEX_0,
                                                 0,  // p1x
                                                 127,   //319,   //239,  // p1y
                                                 159,   //239,   //319,  // p2x
                                                 0); // p2y
                        break;
                }               
                case Line5:
                {
                        GFX_ColorSet(GFX_INDEX_0, GFX_RGBConvert(0xF8, 0xFC, 0xF8));
                        GFX_LineStyleSet(GFX_INDEX_0, GFX_LINE_STYLE_THIN_SOLID);
                        GFX_LineDraw(GFX_INDEX_0,
                                                 0,  // p1x
                                                 0,  // p1y
                                                 159,   //239,   //319,  // p2x
                                                 127);  //319);   //239); // p2y
                        break;
                }               
                case Line4: //LIGHT GREEN
                {
                        GFX_ColorSet(GFX_INDEX_0, GFX_RGBConvert(0x00, 0xFC, 0x00));
                        GFX_LineStyleSet(GFX_INDEX_0, GFX_LINE_STYLE_THIN_SOLID);
                        GFX_LineDraw(GFX_INDEX_0,
                                                 159,   //239,   //319,  // p1x
                                                 0,  // p1y
                                                 159,   //239,   //319,  // p2x
                                                 127);  //319);  //239); // p2y
                        break;
                }               
                case Line3: //YELLOW
                {
                        GFX_ColorSet(GFX_INDEX_0, GFX_RGBConvert(0xF8, 0xFC, 0x00));
                        GFX_LineStyleSet(GFX_INDEX_0, GFX_LINE_STYLE_THIN_SOLID);
                        GFX_LineDraw(GFX_INDEX_0,
                                                 0,  // p1x
                                                 0,  // p1y
                                                 0,  // p2x
                                                 127);  //319);  //239); // p2y
                        break;
                }               
                case Line2: //BLUE
                {
                        GFX_ColorSet(GFX_INDEX_0, GFX_RGBConvert(0x00, 0x00, 0xF8));
                        GFX_LineStyleSet(GFX_INDEX_0, GFX_LINE_STYLE_THIN_SOLID);
                        GFX_LineDraw(GFX_INDEX_0,
                                                 0,  // p1x
                                                 127,   //319,   //239,  // p1y
                                                 159,   //239,   //319,  // p2x
                                                 127);   //319);  //239); // p2y
                        break;
                }               
                case Line1: //RED
                {
                        GFX_ColorSet(GFX_INDEX_0, GFX_RGBConvert(0xF8, 0x00, 0x00));
                        GFX_LineStyleSet(GFX_INDEX_0, GFX_LINE_STYLE_THIN_SOLID);
                        GFX_LineDraw(GFX_INDEX_0,
                                                 0,  // p1x
                                                 0,  // p1y
                                                 159,   //239,   //319,  // p2x
                                                 0); // p2y
                        break;
                }               
                case Rectangle5:
                {
                        GFX_ColorSet(GFX_INDEX_0, GFX_RGBConvert(0x00, 0x00, 0xF8));
                        GFX_LineStyleSet(GFX_INDEX_0, GFX_LINE_STYLE_THIN_SOLID);
                        GFX_RectangleDraw(GFX_INDEX_0,
                                                          160/2-60, //65-40,  // p1x
                                                          128/2-60, //30+40,  // p1y
                                                          160/2+60, //255-40,  // p2x
                                                          128/2+60);    //210+40); // p2y
                        
                        break;
                }       
                case Rectangle4:
                {
                        GFX_ColorSet(GFX_INDEX_0, GFX_RGBConvert(0x00, 0x00, 0xF8));
                        GFX_LineStyleSet(GFX_INDEX_0, GFX_LINE_STYLE_THIN_SOLID);
                        GFX_RectangleDraw(GFX_INDEX_0,
                                                          160/2-53, //80-40,  // p1x
                                                          128/2-53, //45+40,  // p1y
                                                          160/2+53, //240-40,  // p2x
                                                          128/2+53);    //195+40); // p2y
                        
                        break;
                }       
                case Rectangle1:    //RED SOLID
                {
                        GFX_FillStyleSet(GFX_INDEX_0, GFX_FILL_STYLE_ALPHA_COLOR);
                        GFX_ColorSet(GFX_INDEX_0, GFX_RGBConvert(0xF8, 0x00, 0x00));
                        GFX_AlphaBlendingValueSet(GFX_INDEX_0, 100);
                        GFX_RectangleFillDraw(GFX_INDEX_0,
                                                                  160/2-15,    //125-40,  // p1x
                                                                  128/2-15,     //90+40,  // p1y
                                                                  160/2+15,    //195-40,  // p2x
                                                                  128/2+15);    //150+40); // p2y
                        
                        GFX_ColorSet(GFX_INDEX_0, GFX_RGBConvert(0xF8, 0x00, 0x00));
                        GFX_LineStyleSet(GFX_INDEX_0, GFX_LINE_STYLE_THIN_SOLID);
                        GFX_RectangleDraw(GFX_INDEX_0,
                                160/2-15,    //125-40,  // p1x
                                                                  128/2-15,     //90+40,  // p1y
                                                                  160/2+15,    //195-40,  // p2x
                                                                  128/2+15);    //150+40); // p2y
                               
                    
                        
                        break;
                }       
                case Rectangle3:    //YELLOW GREEN SOLID
                {
                        GFX_FillStyleSet(GFX_INDEX_0, GFX_FILL_STYLE_COLOR);
                        GFX_ColorSet(GFX_INDEX_0, GFX_RGBConvert(0x00, 0xFC, 0x00));
                        GFX_RectangleFillDraw(GFX_INDEX_0,
                                                                  160/2-30, //110-40,  // p1x
                                                                  128/2-30, //75+40,  // p1y
                                                                  160/2+30, //210-40,  // p2x
                                                                  128/2+30);    //165+40); // p2y
                        
                        GFX_ColorSet(GFX_INDEX_0, GFX_RGBConvert(0x00, 0xFC, 0x00));
                        GFX_LineStyleSet(GFX_INDEX_0, GFX_LINE_STYLE_THIN_SOLID);
                        GFX_RectangleDraw(GFX_INDEX_0,
                                                          160/2-30, //110-40,  // p1x
                                                                  128/2-30, //75+40,  // p1y
                                                                  160/2+30, //210-40,  // p2x
                                                                  128/2+30);    //165+40); // p2y
                        
                        break;
                }       
                case Rectangle2:
                {
                        GFX_FillStyleSet(GFX_INDEX_0, GFX_FILL_STYLE_COLOR);
                        GFX_ColorSet(GFX_INDEX_0, GFX_RGBConvert(0x00, 0x00, 0xF8));
                        GFX_RectangleFillDraw(GFX_INDEX_0,
                                                                  160/2-45, //95-40,  // p1x
                                                                  128/2-45, //60+40,  // p1y
                                                                  160/2+45, //225-40,  // p2x
                                                                  128/2+45);    //180+40); // p2y
                        
                        GFX_ColorSet(GFX_INDEX_0, GFX_RGBConvert(0x00, 0x00, 0xF8));
                        GFX_LineStyleSet(GFX_INDEX_0, GFX_LINE_STYLE_THIN_SOLID);
                        GFX_RectangleDraw(GFX_INDEX_0,
                                 160/2-45, //95-40,  // p1x
                                                                  128/2-45, //60+40,  // p1y
                                                                  160/2+45, //225-40,  // p2x
                                                                  128/2+45);    //180+40); // p2y
                                                         
                        
                        break;
                }       
                case Circle10:
                {
                        GFX_ColorSet(GFX_INDEX_0,GFX_RGBConvert(0xF8, 0x00, 0x00));
                        GFX_LineStyleSet(GFX_INDEX_0, GFX_LINE_STYLE_THIN_SOLID);
                        GFX_CircleDraw(GFX_INDEX_0,
                                                   80,//120, //160, // p1x
                                                   64,  //160, //120, // p1y
                                                   3); // radius
                                                   
                        break;
                }       
                case Circle9:
                {
                        GFX_ColorSet(GFX_INDEX_0,GFX_RGBConvert(0xF8, 0x00, 0x00));
                        GFX_LineStyleSet(GFX_INDEX_0, GFX_LINE_STYLE_THIN_SOLID);
                        GFX_CircleDraw(GFX_INDEX_0,
                                                   80,  //120, //160, // p1x
                                                   64,  //160, //120, // p1y
                                                   16); // radius
                                                   
                        break;
                }       
                case Circle8:
                {
                        GFX_ColorSet(GFX_INDEX_0,GFX_RGBConvert(0xF8, 0x00, 0x00));
                        GFX_LineStyleSet(GFX_INDEX_0, GFX_LINE_STYLE_THIN_SOLID);
                        GFX_CircleDraw(GFX_INDEX_0,
                                                   80,  //120, //160, // p1x
                                                   64,  //160, //120, // p1y
                                                   29); // radius
                                                   
                        break;
                }       
                case Circle7:
                {
                        GFX_ColorSet(GFX_INDEX_0,GFX_RGBConvert(0xF8, 0x00, 0x00));
                        GFX_LineStyleSet(GFX_INDEX_0, GFX_LINE_STYLE_THIN_SOLID);
                        GFX_CircleDraw(GFX_INDEX_0,
                                                   80,  //120, //160, // p1x
                                                   64,  //160, //120, // p1y
                                                   42); // radius
                                                   
                        break;
                }       
                case Circle6:
                {
                        GFX_ColorSet(GFX_INDEX_0,GFX_RGBConvert(0xF8, 0x00, 0x00));
                        GFX_LineStyleSet(GFX_INDEX_0, GFX_LINE_STYLE_THIN_SOLID);
                        GFX_CircleDraw(GFX_INDEX_0,
                                                   80,  //120, //160, // p1x
                                                   64,  //160, //120, // p1y
                                                   55); // radius
                                                   
                        break;
                }       
                case Circle5:
                {
          /*  
                        GFX_ColorSet(GFX_INDEX_0,GFX_RGBConvert(0xF8, 0x00, 0x00));
                        GFX_LineStyleSet(GFX_INDEX_0, GFX_LINE_STYLE_THIN_SOLID);
                        GFX_CircleDraw(GFX_INDEX_0,
                                                   120, //160, // p1x
                                                   160, //120, // p1y
                                                   68); // radius
                */                         
                        break;
                }       
                case Circle4:
                {
          /*  
                        GFX_ColorSet(GFX_INDEX_0,GFX_RGBConvert(0xF8, 0x00, 0x00));
                        GFX_LineStyleSet(GFX_INDEX_0, GFX_LINE_STYLE_THIN_SOLID);
                        GFX_CircleDraw(GFX_INDEX_0,
                                                   120, //160, // p1x
                                                   160, //120, // p1y
                                                   81); // radius
                */                         
                        break;
                }       
                case Circle3:
                {
        /*    
                        GFX_ColorSet(GFX_INDEX_0,GFX_RGBConvert(0xF8, 0x00, 0x00));
                        GFX_LineStyleSet(GFX_INDEX_0, GFX_LINE_STYLE_THIN_SOLID);
                        GFX_CircleDraw(GFX_INDEX_0,
                                                   120, //160, // p1x
                                                   160, //120, // p1y
                                                   94); // radius
                */                                 
                        break;
                }       
                case Circle2:
                {
         /*   
                        GFX_ColorSet(GFX_INDEX_0,GFX_RGBConvert(0xF8, 0x00, 0x00));
                        GFX_LineStyleSet(GFX_INDEX_0, GFX_LINE_STYLE_THIN_SOLID);
                        GFX_CircleDraw(GFX_INDEX_0,
                                                   120, //160, // p1x
                                                   160, //120, // p1y
                                                   107); // radius
                */                                 
                        break;
                }       
                case Circle1:
                {
     /*
                        GFX_ColorSet(GFX_INDEX_0,GFX_RGBConvert(0xF8, 0x00, 0x00));
                        GFX_LineStyleSet(GFX_INDEX_0, GFX_LINE_STYLE_THIN_SOLID);
                        GFX_CircleDraw(GFX_INDEX_0,
                                                   120, //160, // p1x
                                                   160, //120, // p1y
                                                   120); // radius
                */                                 
                        break;
                }       
        default:
                return false; // process by default
    }

    return true;
}

/******************************************************************************
  Function: 
    bool GFX_HGC_MsgStaticTexts(uint16_t objMsg, GFX_GOL_OBJ_HEADER *pObj)

  Output:
    Returns true if a Object ID matches an existing item identifier

  Remarks: 
    Handles GFX GOL Static Text events
 */
bool GFX_HGC_MsgStaticTexts(uint16_t objMsg, GFX_GOL_OBJ_HEADER *pObj)
{
    switch (GFX_GOL_ObjectIDGet(pObj))
    {
        default:
            return false; // default false as it is not processed
    }    
}

/******************************************************************************
  Function: 
    bool GFX_HGC_MsgPictures(uint16_t objMsg, GFX_GOL_OBJ_HEADER *pObj)

  Output:
    Returns true if a Object ID matches an existing item identifier

  Remarks: 
    Handles GFX GOL Picture Control events
 */
bool GFX_HGC_MsgPictures(uint16_t objMsg, GFX_GOL_OBJ_HEADER *pObj)
{
    switch (GFX_GOL_ObjectIDGet(pObj))
    {
        default:
            return false; // default false as it is not processed
    }    
}












 <動作結果>
1. ピクチャー
  以下、各画面

    各液晶画面 
 画面@    
  画面A   
  画面B   


2. 動画 -----> YouTube



■ マイクロチップ デモソフト”Primitive”  at PIC32MZ + INT022 

   
  <試作品仕様>
   ・ Harmonyのグラフィックライブラリのサンプルデモソフトとして マイクロチップから提供されている
      ”Primitive"(C:\microchip\harmony\v1_05\apps\gfx\primitive)を
     下記ハードウェアで実行する
      @ PIC: PIC32MZ2048EFH100
      A 液晶: (株)ディスプレーテック INT022 QVGA(320 x240)、2.2インチ
   
   ・ 開発環境  Harmony ver.1.06、  XC32 ver.1.40、  MPLABX 3.15  PIC32MZ2048EFH  revison 1
  

  <試作品回路図>(→回路図のPDFファイル


<試作品外観>下記の写真には上記回路図にはない、また本テーマと関係のない部品が多々写っています



   

          

   <プログラム例>

//以下、main.c
//------------------------------------------------------------------------------------------
/*******************************************************************************
  MPLAB Harmony Project Main Source File

  Company:
    Microchip Technology Inc.
  
  File Name:
    main.c

  Summary:
    This file contains the "main" function for an MPLAB Harmony project.

  Description:
    This file contains the "main" function for an MPLAB Harmony project.  The
    "main" function calls the "SYS_Initialize" function to initialize the state 
    machines of all MPLAB Harmony modules in the system and it calls the 
    "SYS_Tasks" function from within a system-wide "super" loop to maintain 
    their correct operation. These two functions are implemented in 
    configuration-specific files (usually "system_init.c" and "system_tasks.c")
    in a configuration-specific folder under the "src/system_config" folder 
    within this project's top-level folder.  An MPLAB Harmony project may have
    more than one configuration, each contained within it's own folder under
    the "system_config" folder.
 *******************************************************************************/

// DOM-IGNORE-BEGIN
/*******************************************************************************
Copyright (c) 2013-2014 released Microchip Technology Inc.  All rights reserved.

//Microchip licenses to you the right to use, modify, copy and distribute
Software only when embedded on a Microchip microcontroller or digital signal
controller that is integrated into your product or third party product
(pursuant to the sublicense terms in the accompanying license agreement).

You should refer to the license agreement accompanying this Software for
additional information regarding your rights and obligations.

SOFTWARE AND DOCUMENTATION ARE PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND,
EITHER EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION, ANY WARRANTY OF
MERCHANTABILITY, TITLE, NON-INFRINGEMENT AND FITNESS FOR A PARTICULAR PURPOSE.
IN NO EVENT SHALL MICROCHIP OR ITS LICENSORS BE LIABLE OR OBLIGATED UNDER
CONTRACT, NEGLIGENCE, STRICT LIABILITY, CONTRIBUTION, BREACH OF WARRANTY, OR
OTHER LEGAL EQUITABLE THEORY ANY DIRECT OR INDIRECT DAMAGES OR EXPENSES
INCLUDING BUT NOT LIMITED TO ANY INCIDENTAL, SPECIAL, INDIRECT, PUNITIVE OR
CONSEQUENTIAL DAMAGES, LOST PROFITS OR LOST DATA, COST OF PROCUREMENT OF
SUBSTITUTE GOODS, TECHNOLOGY, SERVICES, OR ANY CLAIMS BY THIRD PARTIES
(INCLUDING BUT NOT LIMITED TO ANY DEFENSE THEREOF), OR OTHER SIMILAR COSTS.
 *******************************************************************************/
// DOM-IGNORE-END


// *****************************************************************************
// *****************************************************************************
// Section: Included Files
// *****************************************************************************
// *****************************************************************************

#include <stddef.h>                     // Defines NULL
#include <stdbool.h>                    // Defines true
#include <stdlib.h>                     // Defines EXIT_FAILURE
#include "system/common/sys_module.h"   // SYS function prototypes


// *****************************************************************************
// *****************************************************************************
// Section: Main Entry Point
// *****************************************************************************
// *****************************************************************************

int main ( void )
{
    /* Initialize all MPLAB Harmony modules, including application(s). */
    SYS_Initialize ( NULL );


    while ( true )
    {
        /* Maintain state machines of all polled MPLAB Harmony modules. */
        SYS_Tasks ( );

    }

    /* Execution should not come here during normal operation */

    return ( EXIT_FAILURE );
}


/*******************************************************************************
 End of File
*/






//以下、app.c
//------------------------------------------------------------------------------------------



/*******************************************************************************
  MPLAB Harmony Application Source File
  
  Company:
    Microchip Technology Inc.
  
  File Name:
    app.c

  Summary:
    This file contains the source code for the MPLAB Harmony application.

  Description:
    This file contains the source code for the MPLAB Harmony application.  It 
    implements the logic of the application's state machine and it may call 
    API routines of other MPLAB Harmony modules in the system, such as drivers,
    system services, and middleware.  However, it does not call any of the
    system interfaces (such as the "Initialize" and "Tasks" functions) of any of
    the modules in the system or make any assumptions about when those functions
    are called.  That is the responsibility of the configuration-specific system
    files.
 *******************************************************************************/

// DOM-IGNORE-BEGIN
/*******************************************************************************
Copyright (c) 2013-2014 released Microchip Technology Inc.  All rights reserved.

Microchip licenses to you the right to use, modify, copy and distribute
Software only when embedded on a Microchip microcontroller or digital signal
controller that is integrated into your product or third party product
(pursuant to the sublicense terms in the accompanying license agreement).

You should refer to the license agreement accompanying this Software for
additional information regarding your rights and obligations.

SOFTWARE AND DOCUMENTATION ARE PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND,
EITHER EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION, ANY WARRANTY OF
MERCHANTABILITY, TITLE, NON-INFRINGEMENT AND FITNESS FOR A PARTICULAR PURPOSE.
IN NO EVENT SHALL MICROCHIP OR ITS LICENSORS BE LIABLE OR OBLIGATED UNDER
CONTRACT, NEGLIGENCE, STRICT LIABILITY, CONTRIBUTION, BREACH OF WARRANTY, OR
OTHER LEGAL EQUITABLE THEORY ANY DIRECT OR INDIRECT DAMAGES OR EXPENSES
INCLUDING BUT NOT LIMITED TO ANY INCIDENTAL, SPECIAL, INDIRECT, PUNITIVE OR
CONSEQUENTIAL DAMAGES, LOST PROFITS OR LOST DATA, COST OF PROCUREMENT OF
SUBSTITUTE GOODS, TECHNOLOGY, SERVICES, OR ANY CLAIMS BY THIRD PARTIES
(INCLUDING BUT NOT LIMITED TO ANY DEFENSE THEREOF), OR OTHER SIMILAR COSTS.
 *******************************************************************************/
// DOM-IGNORE-END


// *****************************************************************************
// *****************************************************************************
// Section: Included Files 
// *****************************************************************************
// *****************************************************************************

#include "app.h"
#include "1lcd_lib_C32.h"


int delay_Clock = 200000000;   //200MHz

void delay_us(volatile unsigned int usec)        //1μsec遅延
{
        volatile  int count;

        count = (int)(delay_Clock/20000000)*usec;


        do      //実測 at 200MH (Clock=200000000)
        {       //delay_us(1000):1000.4μsec  delay_us(100):100.6μsec  delay_us(10):10.5μsec  delay_us(1):1.5μsec
                asm("NOP"); asm("NOP"); asm("NOP"); asm("NOP"); asm("NOP");asm("NOP");
                asm("NOP"); asm("NOP"); asm("NOP"); asm("NOP"); asm("NOP"); asm("NOP");

                count--;
        }while(count != 0);


}

void delay_ms(volatile unsigned int msec)        //1msec遅延
{
        volatile unsigned int i;         //実測:at200MH (Clock=200000000)//delay_ms(1): 1.0006msec   delay_ms(100):100.04msec

        for(i=0; i<msec; i++)
        delay_us(1000);
}



// *****************************************************************************
// *****************************************************************************
// Section: Global Data Definitions
// *****************************************************************************
// *****************************************************************************

// *****************************************************************************
/* Application Data

  Summary:
    Holds application data

  Description:
    This structure holds the application's data.

  Remarks:
    This structure should be initialized by the APP_Initialize function.
    
    Application strings and buffers are be defined outside this structure.
*/

APP_DATA appData;





// *****************************************************************************
// *****************************************************************************
// Section: MACROS
// *****************************************************************************
// *****************************************************************************
#define MIN(x,y)                ((x > y)? y: x)
#define APP_SCREEN_DELAY_MS         (1000)
// *****************************************************************************
// *****************************************************************************
// Section: Global Variable Definitions
// *****************************************************************************
// *****************************************************************************

// *****************************************************************************
// *****************************************************************************
// Section: Application Local Routines
// *****************************************************************************
void APP_TMR_DelayMS ( unsigned int delayMs );


// *****************************************************************************
// *****************************************************************************
// Section: Application Callback Functions
// *****************************************************************************
// *****************************************************************************

/* TODO:  Add any necessary callback funtions.
*/

// *****************************************************************************
// *****************************************************************************
// Section: Application Local Functions
// *****************************************************************************
// *****************************************************************************

/* TODO:  Add any necessary local functions.
*/


// *****************************************************************************
// *****************************************************************************
// Section: Application Initialization and State Machine Functions
// *****************************************************************************
// *****************************************************************************

/*******************************************************************************
  Function:
    void APP_Initialize ( void )

  Remarks:
    See prototype in app.h.
 */

void APP_Initialize ( void )
{
    /* Place the App state machine in its initial state. */
    appData.state = APP_STATE_INIT;
    
    /* TODO: Initialize your application's state machine and other
     * parameters.
     */
}


/******************************************************************************
  Function:
    void APP_Tasks ( void )

  Remarks:
    See prototype in app.h.
 */

void APP_Tasks ( void )
{
    /* Check the application's current state. */
    switch ( appData.state )
    {
        /* Application's initial state. */
        case APP_STATE_INIT:
        {
            appData.state = APP_HGC_SCREEN1_DRAW;
            break;
        }
        
        case APP_HGC_SCREEN1_DRAW:
        {
            if(hgcObj.screenState != HGC_SCREEN_STATE_DISPLAY_SCREEN_screen1)
                return;
            
            GFX_HGC_ChangeScreen(screen2);
            APP_TMR_DelayMS(1000);
            appData.state = APP_HGC_SCREEN2_DRAW;
            
            break;
        }    

        case APP_HGC_SCREEN2_DRAW:
        {
            if(hgcObj.screenState != HGC_SCREEN_STATE_DISPLAY_SCREEN_screen2)
                return;
            
            GFX_HGC_ChangeScreen(screen3);
            APP_TMR_DelayMS(1000);
            appData.state = APP_HGC_SCREEN3_DRAW;
            break;
        }
        
        case APP_HGC_SCREEN3_DRAW:
        {
            if(hgcObj.screenState != HGC_SCREEN_STATE_DISPLAY_SCREEN_screen3)
                return;
            
            GFX_HGC_ChangeScreen(screen1);
            APP_TMR_DelayMS(1000);
            appData.state = APP_HGC_SCREEN1_DRAW;
            break;
        }    

        /* The default state should never be executed. */
        default:
        {
            /* TODO: Handle error in application's state machine. */
            break;
        }
    }
}

void APP_TMR_DelayMS ( unsigned int delayMs )
{
    if(delayMs)
    {
        uint32_t sysClk = SYS_CLK_FREQ;
        uint32_t t0;
        t0 = _CP0_GET_COUNT();
        while (_CP0_GET_COUNT() - t0 < (sysClk/2000)*delayMs);
    }
}

/*******************************************************************************
 End of File
 */









//以下、system_init.c
//---------------------------------------------------------------------------------
/*******************************************************************************
  System Initialization File

  File Name:
    system_init.c

  Summary:
    This file contains source code necessary to initialize the system.

  Description:
    This file contains source code necessary to initialize the system.  It
    implements the "SYS_Initialize" function, defines the configuration bits, 
    and allocates any necessary global system resources, such as the 
    sysObj structure that contains the object handles to all the MPLAB Harmony 
    module objects in the system.
 *******************************************************************************/

// DOM-IGNORE-BEGIN
/*******************************************************************************
Copyright (c) 2013-2015 released Microchip Technology Inc.  All rights reserved.

Microchip licenses to you the right to use, modify, copy and distribute
Software only when embedded on a Microchip microcontroller or digital signal
controller that is integrated into your product or third party product
(pursuant to the sublicense terms in the accompanying license agreement).

You should refer to the license agreement accompanying this Software for
additional information regarding your rights and obligations.

SOFTWARE AND DOCUMENTATION ARE PROVIDED AS IS WITHOUT WARRANTY OF ANY KIND,
EITHER EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION, ANY WARRANTY OF
MERCHANTABILITY, TITLE, NON-INFRINGEMENT AND FITNESS FOR A PARTICULAR PURPOSE.
IN NO EVENT SHALL MICROCHIP OR ITS LICENSORS BE LIABLE OR OBLIGATED UNDER
CONTRACT, NEGLIGENCE, STRICT LIABILITY, CONTRIBUTION, BREACH OF WARRANTY, OR
OTHER LEGAL EQUITABLE THEORY ANY DIRECT OR INDIRECT DAMAGES OR EXPENSES
INCLUDING BUT NOT LIMITED TO ANY INCIDENTAL, SPECIAL, INDIRECT, PUNITIVE OR
CONSEQUENTIAL DAMAGES, LOST PROFITS OR LOST DATA, COST OF PROCUREMENT OF
SUBSTITUTE GOODS, TECHNOLOGY, SERVICES, OR ANY CLAIMS BY THIRD PARTIES
(INCLUDING BUT NOT LIMITED TO ANY DEFENSE THEREOF), OR OTHER SIMILAR COSTS.
 *******************************************************************************/
// DOM-IGNORE-END


// *****************************************************************************
// *****************************************************************************
// Section: Included Files
// *****************************************************************************
// *****************************************************************************

#include "system_config.h"
#include "system_definitions.h"


// ****************************************************************************
// ****************************************************************************
// Section: Configuration Bits
// ****************************************************************************
// ****************************************************************************
// <editor-fold defaultstate="collapsed" desc="Configuration Bits">

/*** DEVCFG0 ***/

#pragma config DEBUG =      OFF
#pragma config JTAGEN =     OFF
#pragma config ICESEL =     ICS_PGx1
#pragma config TRCEN =      OFF
#pragma config BOOTISA =    MIPS32
#pragma config FECCCON =    OFF_UNLOCKED
#pragma config FSLEEP =     OFF
#pragma config DBGPER =     PG_ALL
#pragma config EJTAGBEN =   NORMAL
#pragma config CP =         OFF

/*** DEVCFG1 ***/

#pragma config FNOSC =      SPLL
#pragma config DMTINTV =    WIN_127_128
#pragma config FSOSCEN =    OFF
#pragma config IESO =       OFF
#pragma config POSCMOD =    EC
#pragma config OSCIOFNC =   OFF
#pragma config FCKSM =      CSECME
#pragma config WDTPS =      PS1048576
#pragma config WDTSPGM =    STOP
#pragma config FWDTEN =     OFF
#pragma config WINDIS =     NORMAL
#pragma config FWDTWINSZ =  WINSZ_25
#pragma config DMTCNT =     DMT31
#pragma config FDMTEN =     OFF

/*** DEVCFG2 ***/

#pragma config FPLLIDIV =   DIV_3
#pragma config FPLLRNG =    RANGE_5_10_MHZ

#pragma config FPLLICLK =   PLL_POSC
#pragma config FPLLMULT =   MUL_50
#pragma config FPLLODIV =   DIV_2
#pragma config UPLLFSEL =   FREQ_24MHZ
//#pragma config UPLLEN =     ON

/*** DEVCFG3 ***/

#pragma config USERID =     0xffff
#pragma config FMIIEN =     ON
#pragma config FETHIO =     ON
#pragma config PGL1WAY =    ON
#pragma config PMDL1WAY =   ON
#pragma config IOL1WAY =    ON
#pragma config FUSBIDIO =   ON

/*** BF1SEQ0 ***/

#pragma config TSEQ =       0xffff
#pragma config CSEQ =       0xffff
// </editor-fold>


// *****************************************************************************
// *****************************************************************************
// Section: Library/Stack Initialization Data
// *****************************************************************************
// *****************************************************************************



// *****************************************************************************
// *****************************************************************************
// Section: Driver Initialization Data
// *****************************************************************************
// *****************************************************************************


// </editor-fold>

DRV_GFX_INIT drvGfxInit =
{
    .orientation             = DISP_ORIENTATION,
    .horizontalResolution    = DISP_HOR_RESOLUTION,
    .verticalResolution      = DISP_VER_RESOLUTION,
    
/*
    .dataWidth               = DISP_DATA_WIDTH,
    .horizontalPulseWidth    = DISP_HOR_PULSE_WIDTH,
    .horizontalBackPorch     = DISP_HOR_BACK_PORCH,
    .horizontalFrontPorch    = DISP_HOR_FRONT_PORCH,
    .verticalPulseWidth      = DISP_VER_PULSE_WIDTH,
    .verticalBackPorch       = DISP_VER_BACK_PORCH,
    .verticalFrontPorch      = DISP_VER_FRONT_PORCH,
    .logicShift              = DISP_INV_LSHIFT,
    .LCDType                 = 1,
    .colorType               = 0,
    .TCON_Init               = TCON_MODULE,
 */ 
    
};





// *****************************************************************************
// *****************************************************************************
// Section: System Data
// *****************************************************************************
// *****************************************************************************

/* Structure to hold the object handles for the modules in the system. */
SYSTEM_OBJECTS sysObj;


// *****************************************************************************
// *****************************************************************************
// Section: Module Initialization Data
// *****************************************************************************
// *****************************************************************************

/*** GFX Initialization Data ***/

 const GFX_INIT gfxInit0 =
{
    .drvInitialize    = NULL,
    
   
    .drvOpen          = DRV_GFX_INT028_Open,
    .drvInterfaceSet  = DRV_GFX_INT028_InterfaceSet, 
  //  .drvOpen          = DRV_GFX_SSD1926_Open,
  //  .drvInterfaceSet  = DRV_GFX_SSD1926_InterfaceSet,
};

/*******************************************************************************
  Device Control System Service Initialization Data
  
  <editor-fold defaultstate="collapsed" 
  desc="Device Control System Service Initialization Data">
*/

const SYS_DEVCON_INIT sysDevconInit =
{
    .moduleInit = {0},
};

// </editor-fold>


// *****************************************************************************
// *****************************************************************************
// Section: Static Initialization Functions
// *****************************************************************************
// *****************************************************************************


// *****************************************************************************
// *****************************************************************************
// Section: System Initialization
// *****************************************************************************
// *****************************************************************************




void ys_PMP_Initialize(void)
{

    short pClockPeriod = 1000000000 / 100000000;
    
    // PMP setup
    PMMODE = 0;
    PMAEN = 0;
    PMCON = 0;
    PMMODEbits.MODE = 2;                // Intel 8080 master interface

    #if (PMP_DATA_SETUP_TIME == 0)
        PMMODEbits.WAITB = 0;
    #else
        if (PMP_DATA_SETUP_TIME <= pClockPeriod)
            PMMODEbits.WAITB = 0;
        else if (PMP_DATA_SETUP_TIME > pClockPeriod)
            PMMODEbits.WAITB = (PMP_DATA_SETUP_TIME / pClockPeriod) + 1;
    #endif

    #if (PMP_DATA_WAIT_TIME == 0)
        PMMODEbits.WAITM = 0;
    #else
        if (PMP_DATA_WAIT_TIME <= pClockPeriod)
            PMMODEbits.WAITM = 1;
        else if (PMP_DATA_WAIT_TIME > pClockPeriod)
            PMMODEbits.WAITM = (PMP_DATA_WAIT_TIME / pClockPeriod) + 1;
    #endif

    #if (PMP_DATA_HOLD_TIME == 0)
        PMMODEbits.WAITE = 0;
    #else
        if (PMP_DATA_HOLD_TIME <= pClockPeriod)
            PMMODEbits.WAITE = 0;
        else if (PMP_DATA_HOLD_TIME > pClockPeriod)
            PMMODEbits.WAITE = (PMP_DATA_HOLD_TIME / pClockPeriod) + 1;
    #endif

    #if defined(USE_16BIT_PMP)
    PMMODEbits.MODE16 = 1;              // 16 bit mode
    #elif defined(USE_8BIT_PMP)
    PMMODEbits.MODE16 = 0;              // 8 bit mode
    #endif

    PMCONbits.PTRDEN = 1;               // enable RD line
    PMCONbits.PTWREN = 1;               // enable WR line
    PMCONbits.PMPEN = 1;                // enable PMP

    delay_us(200);



}






/*******************************************************************************
  Function:
    void SYS_Initialize ( SYS_INIT_DATA *data )

  Summary:
    Initializes the board, services, drivers, application and other modules.

  Remarks:
    See prototype in system/common/sys_module.h.
 */

void SYS_Initialize ( void* data )
{
     
    
    /* Core Processor Initialization */
    SYS_CLK_Initialize( NULL );
    sysObj.sysDevcon = SYS_DEVCON_Initialize(SYS_DEVCON_INDEX_0, (SYS_MODULE_INIT*)&sysDevconInit);
    SYS_DEVCON_PerformanceConfig(SYS_CLK_SystemFrequencyGet());
    
    delay_ms(2000); //SYS_PORTS_Initialize(); ys_PMP_Initialize(); の前に設定のこと
    
    
    SYS_PORTS_Initialize();
    
     
   /*
    SYS_DEVCON_SystemUnlock();
    //PMP用ペリフェラルクロック低減 100MH → 25MHz
//    PB2DIVbits.PBDIV = 0b1111111;   //1/128
     PB2DIVbits.PBDIV = 0x03;  //PBCLK2 is SYSCLK divided by 4   //  PMP SPI 1/4 = 100MHz / 4 = 25MHz

    SYS_DEVCON_SystemLock();
  */  

    /* Initialize Drivers */

    /* Initialize System Services */

      delay_ms(500);  

//PMP 初期化 Initialize PMP0
    ys_PMP_Initialize();
//    DRV_PMP0_Initialize();
//    DRV_PMP0_ModeConfig();

    
//GFX グラフィック初期化
    DRV_GFX_INT028_Initialize(GFX_INDEX_0, (SYS_MODULE_INIT*)&drvGfxInit);
    //DRV_GFX_SSD1926_Initialize(GFX_INDEX_0, (SYS_MODULE_INIT*)&drvGfxInit);
   

    /* Initialize Middleware */

    sysObj.gfxObject0 = GFX_Initialize(GFX_INDEX_0, (SYS_MODULE_INIT *)&gfxInit0);  //GFX初期化
           
    /* Initialize the Application */
    APP_Initialize();
}


/*******************************************************************************
 End of File
*/






//以下、system_definitons.h
//----------------------------------------------------------------------------------

/*******************************************************************************
  System Definitions

  File Name:
    system_definitions.h

  Summary:
    MPLAB Harmony project system definitions.

  Description:
    This file contains the system-wide prototypes and definitions for an MPLAB
    Harmony project.
 *******************************************************************************/

//DOM-IGNORE-BEGIN
/*******************************************************************************
Copyright (c) 2013-2014 released Microchip Technology Inc.  All rights reserved.

Microchip licenses to you the right to use, modify, copy and distribute
Software only when embedded on a Microchip microcontroller or digital signal
controller that is integrated into your product or third party product
(pursuant to the sublicense terms in the accompanying license agreement).

You should refer to the license agreement accompanying this Software for
additional information regarding your rights and obligations.

SOFTWARE AND DOCUMENTATION ARE PROVIDED AS IS WITHOUT WARRANTY OF ANY KIND,
EITHER EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION, ANY WARRANTY OF
MERCHANTABILITY, TITLE, NON-INFRINGEMENT AND FITNESS FOR A PARTICULAR PURPOSE.
IN NO EVENT SHALL MICROCHIP OR ITS LICENSORS BE LIABLE OR OBLIGATED UNDER
CONTRACT, NEGLIGENCE, STRICT LIABILITY, CONTRIBUTION, BREACH OF WARRANTY, OR
OTHER LEGAL EQUITABLE THEORY ANY DIRECT OR INDIRECT DAMAGES OR EXPENSES
INCLUDING BUT NOT LIMITED TO ANY INCIDENTAL, SPECIAL, INDIRECT, PUNITIVE OR
CONSEQUENTIAL DAMAGES, LOST PROFITS OR LOST DATA, COST OF PROCUREMENT OF
SUBSTITUTE GOODS, TECHNOLOGY, SERVICES, OR ANY CLAIMS BY THIRD PARTIES
(INCLUDING BUT NOT LIMITED TO ANY DEFENSE THEREOF), OR OTHER SIMILAR COSTS.
 *******************************************************************************/
//DOM-IGNORE-END

#ifndef _SYS_DEFINITIONS_H
#define _SYS_DEFINITIONS_H


// *****************************************************************************
// *****************************************************************************
// Section: Included Files
// *****************************************************************************
// *****************************************************************************

#include <stdint.h>
#include <stddef.h>
#include <stdbool.h>
#include "system/common/sys_common.h"
#include "system/common/sys_module.h"
#include "system/clk/sys_clk.h"
#include "system/clk/sys_clk_static.h"
#include "system/devcon/sys_devcon.h"
#include "system/console/sys_console.h"

#include "framework/driver/pmp/drv_pmp_static.h"
#include "driver/tmr/drv_tmr_static.h"
#include "peripheral/int/plib_int.h"
#include "system/ports/sys_ports.h"
#include "gfx/gfx.h"
#include "gfx/gfx_gol.h"
#include "gfx/gfx_gol_scheme.h"


#include "drv_gfx_INT028_24_22.h"     //INT028, INT024, INT022用
//#include "driver/gfx/controller/ssd1926/drv_gfx_ssd1926.h"
#include "system/debug/sys_debug.h"
#include "system/command/sys_command.h"


#include "gfx_hgc_definitions.h"
#include "app.h"


// *****************************************************************************
// *****************************************************************************
// Section: Type Definitions
// *****************************************************************************
// *****************************************************************************

// *****************************************************************************
/* System Objects

  Summary:
    Structure holding the system's object handles

  Description:
    This structure contains the object handles for all objects in the
    MPLAB Harmony project's system configuration.

  Remarks:
    These handles are returned from the "Initialize" functions for each module
    and must be passed into the "Tasks" function for each module.
*/

typedef struct
{
    SYS_MODULE_OBJ  sysDevcon;
    SYS_MODULE_OBJ  gfxObject0;
    
} SYSTEM_OBJECTS;


// *****************************************************************************
// *****************************************************************************
// Section: extern declarations
// *****************************************************************************
// *****************************************************************************

extern SYSTEM_OBJECTS sysObj;

#endif /* _SYS_DEFINITIONS_H */
/*******************************************************************************
 End of File
*/




//以下、gfx_hgc_definitions.h
//--------------------------------------------------------------------------

/*******************************************************************************
  MPLAB Harmony Graphics Composer Generated Definitions Header

  File Name:
    gfx_hgc_definitions.h

  Summary:
    Build-time generated definitions header based on output by the MPLAB Harmony
    Graphics Composer.

  Description:
    Build-time generated definitions header based on output by the MPLAB Harmony
    Graphics Composer.

    Created with MPLAB Harmony Version 1.05
*******************************************************************************/

// DOM-IGNORE-BEGIN
/*******************************************************************************
Copyright (c) 2013-2014 released Microchip Technology Inc.  All rights reserved.

Microchip licenses to you the right to use, modify, copy and distribute
Software only when embedded on a Microchip microcontroller or digital signal
controller that is integrated into your product or third party product
(pursuant to the sublicense terms in the accompanying license agreement).

You should refer to the license agreement accompanying this Software for
additional information regarding your rights and obligations.

SOFTWARE AND DOCUMENTATION ARE PROVIDED AS IS WITHOUT WARRANTY OF ANY KIND,
EITHER EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION, ANY WARRANTY OF
MERCHANTABILITY, TITLE, NON-INFRINGEMENT AND FITNESS FOR A PARTICULAR PURPOSE.
IN NO EVENT SHALL MICROCHIP OR ITS LICENSORS BE LIABLE OR OBLIGATED UNDER
CONTRACT, NEGLIGENCE, STRICT LIABILITY, CONTRIBUTION, BREACH OF WARRANTY, OR
OTHER LEGAL EQUITABLE THEORY ANY DIRECT OR INDIRECT DAMAGES OR EXPENSES
INCLUDING BUT NOT LIMITED TO ANY INCIDENTAL, SPECIAL, INDIRECT, PUNITIVE OR
CONSEQUENTIAL DAMAGES, LOST PROFITS OR LOST DATA, COST OF PROCUREMENT OF
SUBSTITUTE GOODS, TECHNOLOGY, SERVICES, OR ANY CLAIMS BY THIRD PARTIES
(INCLUDING BUT NOT LIMITED TO ANY DEFENSE THEREOF), OR OTHER SIMILAR COSTS.
*******************************************************************************/
// DOM-IGNORE-END


#ifndef _GFX_HGC_DEFINITIONS_H
#define _GFX_HGC_DEFINITIONS_H

#include "system_config.h"
#include "system_definitions.h"

typedef enum
{
    HGC_STATE_INIT = 0,
    HGC_STATE_RUNNING
} HGC_STATES;

typedef enum
{
    HGC_SCREEN_STATE_INIT = 0,
    HGC_SCREEN_STATE_SETUP_SCREEN_screen1,
    HGC_SCREEN_STATE_PRE_DRAW_GOL_SCREEN_screen1,
    HGC_SCREEN_STATE_DRAW_GOL_SCREEN_screen1,
    HGC_SCREEN_STATE_POST_DRAW_GOL_SCREEN_screen1,
    HGC_SCREEN_STATE_PRE_DRAW_PRIMITIVE_SCREEN_screen1,
    HGC_SCREEN_STATE_DRAW_PRIMITIVE_SCREEN_screen1,
    HGC_SCREEN_STATE_POST_DRAW_PRIMITIVE_SCREEN_screen1,
    HGC_SCREEN_STATE_DISPLAY_SCREEN_screen1,
        
    HGC_SCREEN_STATE_SETUP_SCREEN_screen2,
    HGC_SCREEN_STATE_PRE_DRAW_GOL_SCREEN_screen2,
    HGC_SCREEN_STATE_DRAW_GOL_SCREEN_screen2,
    HGC_SCREEN_STATE_POST_DRAW_GOL_SCREEN_screen2,
    HGC_SCREEN_STATE_PRE_DRAW_PRIMITIVE_SCREEN_screen2,
    HGC_SCREEN_STATE_DRAW_PRIMITIVE_SCREEN_screen2,
    HGC_SCREEN_STATE_POST_DRAW_PRIMITIVE_SCREEN_screen2,
    HGC_SCREEN_STATE_DISPLAY_SCREEN_screen2,
        
    HGC_SCREEN_STATE_SETUP_SCREEN_screen3,
    HGC_SCREEN_STATE_PRE_DRAW_GOL_SCREEN_screen3,
    HGC_SCREEN_STATE_DRAW_GOL_SCREEN_screen3,
    HGC_SCREEN_STATE_POST_DRAW_GOL_SCREEN_screen3,
    HGC_SCREEN_STATE_PRE_DRAW_PRIMITIVE_SCREEN_screen3,
    HGC_SCREEN_STATE_DRAW_PRIMITIVE_SCREEN_screen3,
    HGC_SCREEN_STATE_POST_DRAW_PRIMITIVE_SCREEN_screen3,
    HGC_SCREEN_STATE_DISPLAY_SCREEN_screen3,
        
} HGC_SCREEN_STATES;

/*** GFX GOL Scheme Definitions ***/

#define GFX_SCHEME_NAME_0                       "default"
#define GFX_SCHEME_ALPHA_0                      100

#define GFX_SCHEME_BACKGROUND_OFFSET_TOP_0      0
#define GFX_SCHEME_BACKGROUND_OFFSET_LEFT_0     0

#define GFX_SCHEME_PRIMARY_COLOR_RED_0          0x00
#define GFX_SCHEME_PRIMARY_COLOR_GREEN_0        0x00
#define GFX_SCHEME_PRIMARY_COLOR_BLUE_0         0x00

#define GFX_SCHEME_SECONDARY_COLOR_RED_0        0x40
#define GFX_SCHEME_SECONDARY_COLOR_GREEN_0      0x40
#define GFX_SCHEME_SECONDARY_COLOR_BLUE_0       0x40

#define GFX_SCHEME_DISABLED_COLOR_RED_0         0x00
#define GFX_SCHEME_DISABLED_COLOR_GREEN_0       0x00
#define GFX_SCHEME_DISABLED_COLOR_BLUE_0        0x00

#define GFX_SCHEME_BACKGROUND_COLOR_RED_0       0x00
#define GFX_SCHEME_BACKGROUND_COLOR_GREEN_0     0x00
#define GFX_SCHEME_BACKGROUND_COLOR_BLUE_0      0x00

#define GFX_SCHEME_EMBOSS_SIZE_0                3

#define GFX_SCHEME_EMBOSS_LIGHT_COLOR_RED_0     0x00
#define GFX_SCHEME_EMBOSS_LIGHT_COLOR_GREEN_0   0x00
#define GFX_SCHEME_EMBOSS_LIGHT_COLOR_BLUE_0    0x00

#define GFX_SCHEME_EMBOSS_DARK_COLOR_RED_0      0x00
#define GFX_SCHEME_EMBOSS_DARK_COLOR_GREEN_0    0x00
#define GFX_SCHEME_EMBOSS_DARK_COLOR_BLUE_0     0x00

#define GFX_SCHEME_TEXT_PRIMARY_COLOR_RED_0     0xF8
#define GFX_SCHEME_TEXT_PRIMARY_COLOR_GREEN_0   0xFC
#define GFX_SCHEME_TEXT_PRIMARY_COLOR_BLUE_0    0xF8

#define GFX_SCHEME_TEXT_SECONDARY_COLOR_RED_0   0x00
#define GFX_SCHEME_TEXT_SECONDARY_COLOR_GREEN_0 0x00
#define GFX_SCHEME_TEXT_SECONDARY_COLOR_BLUE_0  0x00

#define GFX_SCHEME_TEXT_DISABLED_COLOR_RED_0    0x40
#define GFX_SCHEME_TEXT_DISABLED_COLOR_GREEN_0  0x40
#define GFX_SCHEME_TEXT_DISABLED_COLOR_BLUE_0   0x40

#define GFX_SCHEME_GRADIENT_START_COLOR_RED_0    0x00
#define GFX_SCHEME_GRADIENT_START_COLOR_GREEN_0  0x00
#define GFX_SCHEME_GRADIENT_START_COLOR_BLUE_0   0x00

#define GFX_SCHEME_GRADIENT_END_COLOR_RED_0    0x00
#define GFX_SCHEME_GRADIENT_END_COLOR_GREEN_0  0x00
#define GFX_SCHEME_GRADIENT_END_COLOR_BLUE_0   0x00

#define GFX_SCHEME_FILL_STYLE_0                GFX_FILL_STYLE_COLOR
#define GFX_SCHEME_BACKGROUND_TYPE_0           GFX_BACKGROUND_NONE

                
/*** GFX GOL Button Definitions ***/
#define GFX_STATICTEXT_LEFT_0            13
#define GFX_STATICTEXT_TOP_0             141
#define GFX_STATICTEXT_RIGHT_0           131
#define GFX_STATICTEXT_BOTTOM_0          191
#define GFX_STATICTEXT_STATE_0          GFX_GOL_STATICTEXT_DRAW_STATE
#define GFX_STATICTEXT_TEXT_0            "0x31, 0x36, 0x62, 0x69, 0x74, 0x20, 0x42, 0x50, 0x50, 0x0"
#define GFX_STATICTEXT_ALIGNMENT_0       GFX_ALIGN_LEFT | GFX_ALIGN_TOP
#define GFX_STATICTEXT_SCHEME_0          gfxScheme0
                
/*** static text IDs ***/
#define StaticText1                  700 
        
/*** GFX GOL windows Definitions ***/
#define GFX_PICTURE_LEFT_0            7
#define GFX_PICTURE_TOP_0             8
#define GFX_PICTURE_RIGHT_0           107
#define GFX_PICTURE_BOTTOM_0          137
#define GFX_PICTURE_STATE_0          GFX_GOL_PICTURECONTROL_DRAW_STATE
#define GFX_PICTURE_SCALE_0       1
#define GFX_PICTURE_SCHEME_0          gfxScheme0
                
/*** Pictures IDs ***/
#define Picture1                  800 
        
/*** Line IDs ***/
#define Line11                 950 
        
#define Line10                 951 
        
#define Line9                 952 
        
#define Line8                 953 
        
#define Line7                 954 
        
#define Line6                 955 
        
#define Line5                 956 
        
#define Line4                 957 
        
#define Line3                 958 
        
#define Line2                 959 
        
#define Line1                 960 
        
/*** Rectangle IDs ***/
#define Rectangle5                 1000 
        
#define Rectangle4                 1001 
        
#define Rectangle1                 1002 
        
#define Rectangle3                 1003 
        
#define Rectangle2                 1004 
        
/*** Circle IDs ***/
#define Circle10                 1050 

#define Circle9                 1051 
        
#define Circle8                 1052 
        
#define Circle7                 1053 
        
#define Circle6                 1054 
        
#define Circle5                 1055 
        
#define Circle4                 1056 
        
#define Circle3                 1057 
        
#define Circle2                 1058 
        
#define Circle1                 1059 
        
/*** Screen IDs ***/
#define screen1                 0 
        
#define screen2                 1 

#define screen3                 2 



// *****************************************************************************
/* MPLAB Harmony Graphics Composer Objects

  Summary:
    Structure holding the graphics object handles

  Description:
    This structure contains the object handles for all graphics objects 
    generated by the Harmony Graphics Composer

  Remarks:
*/

typedef struct HGC_OBJECTS
{
    HGC_SCREEN_STATES screenState;      // current state of screen state machine
    HGC_SCREEN_STATES prevRefreshState; // previous state of screen state machine

//    DRV_TOUCH_SAMPLE_POINTS samplePoints;

    /*** GOL Objects References ***/
    GFX_GOL_STATICTEXT* pStaticText1Obj;
    GFX_GOL_PICTURECONTROL* pPicture1Obj;
} HGC_OBJECTS;

extern HGC_OBJECTS hgcObj;

/******************************************************************************
  Function:
    void GFX_HGC_Setup ( void )

  Summary:
    This function sets up the GOL message callback and draw callbacks.  
 */
void GFX_HGC_Setup ( void );


/******************************************************************************
  Function:
    HGC_SCREEN_STATES GFX_HGC_GetScreenState ( void )

  Remarks:
    This function returns the screen state
 */
HGC_SCREEN_STATES GFX_HGC_GetScreenState ( void );


/******************************************************************************
  Function:
    void GFX_HGC_SetScreenState ( HGC_SCREEN_STATES newState )

  Remarks:
    This function sets the screen state machine to a new state
 */
void GFX_HGC_SetScreenState ( HGC_SCREEN_STATES newState );


/******************************************************************************
  Function:
    void GFX_HGC_Tasks (SYS_MODULE_OBJ gfxObject);

  Summary:
    This function is called in SYS_Tasks.  The intent wait until the GFX library
    is initialized before supplying items to draw
*/
void GFX_HGC_Tasks  (SYS_MODULE_OBJ gfxObject);


/******************************************************************************
  Function:
    void GFX_HGC_SchemeCreate ( void )

  Summary:
    Allocates memory for a new scheme
 */
GFX_GOL_OBJ_SCHEME *GFX_HGC_SchemeCreate(void);


/******************************************************************************
  Function:
    void GFX_HGC_InitializeSchemes ( void )

  Summary:
    Initializes all HGC-specified schemes
 */
void GFX_HGC_InitializeSchemes( void );


/******************************************************************************
  Function: 
    bool GFX_HGC_MESSAGECallback(uint16_t objMsg, GFX_GOL_OBJ_HEADER* pObj, GFX_GOL_MESSAGE* pMsg)

  Input: 
    objMsg - translated message for the object,
    pObj - pointer to the object,
    pMsg - pointer to the non-translated, raw GOL message

  Output: 
    If the function returns non-zero the message will be processed by default

  Remarks: 
    GFX_GOL_MESSAGECallback() function calls it each time the valid message for the GOL object is received.
 */
bool GFX_HGC_MessageCallback(GFX_GOL_TRANSLATED_ACTION objMsg, GFX_GOL_OBJ_HEADER *pObj, GFX_GOL_MESSAGE *pMsg);


/******************************************************************************
  Function: 
    bool GFX_HGC_DrawCallback( void )

  Output: 
    If the function returns non-zero the draw control will be passed to GOL

  Remarks: 
    GFX_GOL_Draw() function calls it each time when GOL objects drawing is 
    completed. HGC-specified draw data is grouped by screens states. It takes 
    two states to complete the drawing of each screen.  GFX GOL objects are drawn
    first and then GFX Primitives are drawn next to ensure primitives are not
    covered by GOL objects.
 */
bool GFX_HGC_DrawCallback( void );
/******************************************************************************
  Function: 
    bool GFX_HGC_DrawScreen_GOL( uint8_t  screenId )

  Output: 
    Returns true if a screenId matches an existing screen identifier

  Remarks: 
    HGC-specified GFX GOL objects are drawn here, grouped by screen.
    The draw order is reverse Z-ordered.
 */
bool GFX_HGC_DrawScreen_GOL(uint8_t screenId);


/******************************************************************************
  Function: 
    bool GFX_HGC_DrawScreen_Primitives( uint8_t  screenId )

  Output:
    Returns true if a screenId matches an existing screen identifier

  Remarks: 
    HGC-specified GFX Primitives are drawn here, grouped by screen.
    GFX Primitives are drawn after GFX GOL Objects to make sure GFX GOL Objects
    do not cover GFX Primitives
 */
bool GFX_HGC_DrawScreen_Primitives(uint8_t screenId);


/******************************************************************************
  Function: 
    void GFX_HGC_SetupScreen( uint8_t  screenId )

  Remarks: 
    Clears current screen and starts a fresh screen with its background color
 */
void GFX_HGC_SetupScreen(uint8_t screenId);


/******************************************************************************
  Function: 
    bool GFX_HGC_ChangeScreen( uint8_t  screenId )

  Output: 
    Returns true if a screenId matches an existing screen identifier

  Remarks: 
    Can be called to initiate GFX Library to draw a new screen
 */
bool GFX_HGC_ChangeScreen(uint8_t screenId);


/******************************************************************************
  Function: 
    bool GFX_HGC_DrawItem(int itemId)

  Output:
    Returns true if a itemId matches an existing item identifier

  Remarks: 
    Every item specified in every screen in HGC is listed in this function
 */
bool GFX_HGC_DrawItem(int itemId);


/******************************************************************************
  Function: 
    bool GFX_HGC_MsgPictures(uint16_t objMsg, GFX_GOL_OBJ_HEADER *pObj)

  Output:
    Returns true if a Object ID matches an existing item identifier

  Remarks: 
    Handles GFX GOL Picture Control events
 */
bool GFX_HGC_MsgPictures(uint16_t objMsg, GFX_GOL_OBJ_HEADER *pObj);

/******************************************************************************
  Function: 
    bool GFX_HGC_MsgStaticTexts(uint16_t objMsg, GFX_GOL_OBJ_HEADER *pObj)

  Output:
    Returns true if a Object ID matches an existing item identifier

  Remarks: 
    Handles GFX GOL Static Text events
 */
bool GFX_HGC_MsgStaticTexts(uint16_t objMsg, GFX_GOL_OBJ_HEADER *pObj);

#endif // _GFX_HGC_DEFINITIONS_H
/*******************************************************************************
 End of File
*/



//以下、gfx_hgc_definitions.c
//-------------------------------------------------------------------------
/*******************************************************************************
  MPLAB Harmony Graphics Composer Generated Implementation File

  File Name:
    gfx_hgc_definitions.c

  Summary:
    Build-time generated implementation from the MPLAB Harmony
    Graphics Composer.

  Description:
    Build-time generated implementation from the MPLAB Harmony
    Graphics Composer.

    Created with MPLAB Harmony Version 1.05
*******************************************************************************/
// DOM-IGNORE-BEGIN
/*******************************************************************************
Copyright (c) 2013-2014 released Microchip Technology Inc.  All rights reserved.

Microchip licenses to you the right to use, modify, copy and distribute
Software only when embedded on a Microchip microcontroller or digital signal
controller that is integrated into your product or third party product
(pursuant to the sublicense terms in the accompanying license agreement).

You should refer to the license agreement accompanying this Software for
additional information regarding your rights and obligations.

SOFTWARE AND DOCUMENTATION ARE PROVIDED AS IS WITHOUT WARRANTY OF ANY KIND,
EITHER EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION, ANY WARRANTY OF
MERCHANTABILITY, TITLE, NON-INFRINGEMENT AND FITNESS FOR A PARTICULAR PURPOSE.
IN NO EVENT SHALL MICROCHIP OR ITS LICENSORS BE LIABLE OR OBLIGATED UNDER
CONTRACT, NEGLIGENCE, STRICT LIABILITY, CONTRIBUTION, BREACH OF WARRANTY, OR
OTHER LEGAL EQUITABLE THEORY ANY DIRECT OR INDIRECT DAMAGES OR EXPENSES
INCLUDING BUT NOT LIMITED TO ANY INCIDENTAL, SPECIAL, INDIRECT, PUNITIVE OR
CONSEQUENTIAL DAMAGES, LOST PROFITS OR LOST DATA, COST OF PROCUREMENT OF
SUBSTITUTE GOODS, TECHNOLOGY, SERVICES, OR ANY CLAIMS BY THIRD PARTIES
(INCLUDING BUT NOT LIMITED TO ANY DEFENSE THEREOF), OR OTHER SIMILAR COSTS.
*******************************************************************************/
// DOM-IGNORE-END

#include "gfx_hgc_definitions.h"

/*** Default GFX GOL Scheme ***/
#define GFX_SCHEMEDEFAULT GOLSchemeDefault
extern GFX_GOL_OBJ_SCHEME GFX_SCHEMEDEFAULT;

/*** HGC-specified GFX GOL Scheme ***/
static GFX_GOL_OBJ_SCHEME *gfxScheme0;

/*** Generated Asset References ***/
extern const GFX_RESOURCE_HDR flower16bit;
extern const GFX_RESOURCE_HDR fireflysung;

/*** Generated ASCII Text Labels ***/
static const GFX_XCHAR staticTextStr_0[] = { 0x31, 0x36, 0x62, 0x69, 0x74, 0x20, 0x42, 0x50, 0x50, 0x0 }; // 16bit BPP
/*** HGC Object Global ***/
HGC_OBJECTS hgcObj;
static HGC_STATES hgcState;

/******************************************************************************
  Function:
    HGC_SCREEN_STATES GFX_HGC_GetScreenState ( void )

  Remarks:
    This function returns the screen state
 */
HGC_SCREEN_STATES GFX_HGC_GetScreenState ( void )
{
    return hgcObj.screenState;
}


/******************************************************************************
  Function:
    void GFX_HGC_SetScreenState ( HGC_SCREEN_STATES newState )

  Remarks:
    This function sets the screen state machine to a new state
 */
void GFX_HGC_SetScreenState ( HGC_SCREEN_STATES newState )
{
    hgcObj.prevRefreshState = hgcObj.screenState;
    hgcObj.screenState = newState;
}


/******************************************************************************
  Function:
    void GFX_HGC_Setup ( void )

  Summary:
    This function sets up the GOL message callback and draw callbacks.  
 */
void GFX_HGC_Setup ( void )
{
    GFX_GOL_MessageCallbackSet(GFX_INDEX_0, &GFX_HGC_MessageCallback);
    GFX_GOL_DrawCallbackSet(GFX_INDEX_0, &GFX_HGC_DrawCallback);

    GFX_HGC_InitializeSchemes();

}

/******************************************************************************
  Function:
    void GFX_HGC_Tasks (SYS_MODULE_OBJ gfxObject);

  Summary:
    This function is called in SYS_Tasks.  The intent wait until the GFX library
    is initialized before supplying items to draw
*/
void GFX_HGC_Tasks  (SYS_MODULE_OBJ gfxObject)
{
    switch ( hgcState )
    {
        case HGC_STATE_INIT:
            if (GFX_Status(gfxObject)==SYS_STATUS_READY)
            {
                GFX_HGC_Setup();
                hgcState = HGC_STATE_RUNNING;
            }
            break;

        case HGC_STATE_RUNNING:
            break;

        default:
            break;
    }
}

/******************************************************************************
  Function:
    void GFX_HGC_SchemeCreate ( void )

  Summary:
    Allocates memory for a new scheme
 */
GFX_GOL_OBJ_SCHEME *GFX_HGC_SchemeCreate(void)
{
    GFX_GOL_OBJ_SCHEME  *pTemp;

    pTemp = (GFX_GOL_OBJ_SCHEME *)GFX_malloc(sizeof(GFX_GOL_OBJ_SCHEME));

    if(pTemp != NULL)
    {
        memcpy(pTemp, &GFX_SCHEMEDEFAULT, sizeof(GFX_GOL_OBJ_SCHEME));
    }

    return (pTemp);
}

/******************************************************************************
  Function:
    void GFX_HGC_InitializeSchemes ( void )

  Summary:
    Initializes all HGC-specified schemes
 */
void GFX_HGC_InitializeSchemes( void )
{
    gfxScheme0 = GFX_HGC_SchemeCreate();

#ifndef GFX_CONFIG_ALPHABLEND_DISABLE
    gfxScheme0->AlphaValue =        GFX_SCHEME_ALPHA_0;
#endif
    gfxScheme0->Color0 =            GFX_RGBConvert(GFX_SCHEME_PRIMARY_COLOR_RED_0, GFX_SCHEME_PRIMARY_COLOR_GREEN_0, GFX_SCHEME_PRIMARY_COLOR_BLUE_0);
    gfxScheme0->Color1 =            GFX_RGBConvert(GFX_SCHEME_SECONDARY_COLOR_RED_0, GFX_SCHEME_SECONDARY_COLOR_GREEN_0, GFX_SCHEME_SECONDARY_COLOR_BLUE_0);
    gfxScheme0->ColorDisabled =     GFX_RGBConvert(GFX_SCHEME_DISABLED_COLOR_RED_0, GFX_SCHEME_DISABLED_COLOR_GREEN_0, GFX_SCHEME_DISABLED_COLOR_BLUE_0);
    gfxScheme0->CommonBkColor =     GFX_RGBConvert(GFX_SCHEME_BACKGROUND_COLOR_RED_0, GFX_SCHEME_BACKGROUND_COLOR_GREEN_0, GFX_SCHEME_BACKGROUND_COLOR_BLUE_0);
        gfxScheme0->EmbossSize =        GFX_SCHEME_EMBOSS_SIZE_0;
    gfxScheme0->EmbossDkColor =     GFX_RGBConvert(GFX_SCHEME_EMBOSS_DARK_COLOR_RED_0, GFX_SCHEME_EMBOSS_DARK_COLOR_GREEN_0, GFX_SCHEME_EMBOSS_DARK_COLOR_BLUE_0);
    gfxScheme0->EmbossLtColor =     GFX_RGBConvert(GFX_SCHEME_EMBOSS_LIGHT_COLOR_RED_0, GFX_SCHEME_EMBOSS_LIGHT_COLOR_GREEN_0, GFX_SCHEME_EMBOSS_LIGHT_COLOR_BLUE_0);
        gfxScheme0->TextColor0 =        GFX_RGBConvert(GFX_SCHEME_TEXT_PRIMARY_COLOR_RED_0, GFX_SCHEME_TEXT_PRIMARY_COLOR_GREEN_0, GFX_SCHEME_TEXT_PRIMARY_COLOR_BLUE_0);
    gfxScheme0->TextColor1 =        GFX_RGBConvert(GFX_SCHEME_TEXT_SECONDARY_COLOR_RED_0, GFX_SCHEME_TEXT_SECONDARY_COLOR_GREEN_0, GFX_SCHEME_TEXT_SECONDARY_COLOR_BLUE_0);
    gfxScheme0->TextColorDisabled = GFX_RGBConvert(GFX_SCHEME_TEXT_DISABLED_COLOR_RED_0, GFX_SCHEME_TEXT_DISABLED_COLOR_GREEN_0, GFX_SCHEME_TEXT_DISABLED_COLOR_BLUE_0);
#ifndef GFX_CONFIG_GRADIENT_DISABLE
        gfxScheme0->gradientStartColor = GFX_RGBConvert(GFX_SCHEME_GRADIENT_START_COLOR_RED_0, GFX_SCHEME_GRADIENT_START_COLOR_GREEN_0, GFX_SCHEME_GRADIENT_START_COLOR_BLUE_0);
        gfxScheme0->gradientEndColor = GFX_RGBConvert(GFX_SCHEME_GRADIENT_END_COLOR_RED_0, GFX_SCHEME_GRADIENT_END_COLOR_GREEN_0, GFX_SCHEME_GRADIENT_END_COLOR_BLUE_0);
#endif
    gfxScheme0->CommonBkLeft =      GFX_SCHEME_BACKGROUND_OFFSET_TOP_0;
    gfxScheme0->CommonBkTop =       GFX_SCHEME_BACKGROUND_OFFSET_LEFT_0;
    gfxScheme0->pFont =             (GFX_RESOURCE_HDR*)&fireflysung;
    gfxScheme0->pCommonBkImage =    (GFX_RESOURCE_HDR*)NULL;
        
        gfxScheme0->fillStyle =         GFX_SCHEME_FILL_STYLE_0;
        gfxScheme0->CommonBkType =      GFX_SCHEME_BACKGROUND_TYPE_0;

}

/******************************************************************************
  Function: 
    bool GFX_HGC_MESSAGECallback(uint16_t objMsg, GFX_GOL_OBJ_HEADER* pObj, GFX_GOL_MESSAGE* pMsg)

  Input: 
    objMsg - translated message for the object,
    pObj - pointer to the object,
    pMsg - pointer to the non-translated, raw GOL message

  Output: 
    If the function returns non-zero the message will be processed by default

  Remarks: 
    GFX_GOL_MESSAGECallback() function calls it each time the valid message for the GOL object is received.
 */
bool GFX_HGC_MessageCallback(GFX_GOL_TRANSLATED_ACTION objMsg, GFX_GOL_OBJ_HEADER *pObj, GFX_GOL_MESSAGE *pMsg)
{
    // process messages for demo screens
    switch (hgcObj.screenState)
    {
        case HGC_SCREEN_STATE_DISPLAY_SCREEN_screen1:
            if (GFX_HGC_MsgPictures(objMsg, pObj) == true)
                return true;
            if (GFX_HGC_MsgStaticTexts(objMsg, pObj) == true)
                return true;
            break;
        case HGC_SCREEN_STATE_DISPLAY_SCREEN_screen2:
            if (GFX_HGC_MsgPictures(objMsg, pObj) == true)
                return true;
            if (GFX_HGC_MsgStaticTexts(objMsg, pObj) == true)
                return true;
            break;
        case HGC_SCREEN_STATE_DISPLAY_SCREEN_screen3:
            if (GFX_HGC_MsgPictures(objMsg, pObj) == true)
                return true;
            if (GFX_HGC_MsgStaticTexts(objMsg, pObj) == true)
                return true;
            break;
      default:
            // process message by default
            return true;
    }
    return true;
}

/******************************************************************************
  Function: 
    bool GFX_HGC_DrawCallback( void )

  Output: 
    If the function returns non-zero the draw control will be passed to GOL

  Remarks: 
    GFX_GOL_Draw() function calls it each time when GOL objects drawing is 
    completed. HGC-specified draw data is grouped by screens states. It takes 
    two states to complete the drawing of each screen.  GFX GOL objects are drawn
    first and then GFX Primitives are drawn next to ensure primitives are not
    covered by GOL objects.
 */
bool GFX_HGC_DrawCallback( void )
{
    switch (hgcObj.screenState)
    {
        case HGC_SCREEN_STATE_INIT:
            //Draw the primary screen as selected in the Composer
            GFX_HGC_SetScreenState(HGC_SCREEN_STATE_SETUP_SCREEN_screen1);
            return true;
        case HGC_SCREEN_STATE_SETUP_SCREEN_screen1:
            GFX_HGC_SetScreenState(HGC_SCREEN_STATE_PRE_DRAW_GOL_SCREEN_screen1);
            break;
        case HGC_SCREEN_STATE_PRE_DRAW_GOL_SCREEN_screen1:
            GFX_HGC_SetScreenState(HGC_SCREEN_STATE_DRAW_GOL_SCREEN_screen1);
            break;
        case HGC_SCREEN_STATE_DRAW_GOL_SCREEN_screen1:
            GFX_HGC_SetupScreen(screen1);
            GFX_HGC_DrawScreen_GOL(screen1);
            GFX_HGC_SetScreenState(HGC_SCREEN_STATE_POST_DRAW_GOL_SCREEN_screen1);
            break;
        case HGC_SCREEN_STATE_POST_DRAW_GOL_SCREEN_screen1:
            GFX_HGC_SetScreenState(HGC_SCREEN_STATE_PRE_DRAW_PRIMITIVE_SCREEN_screen1);
            break;
        case HGC_SCREEN_STATE_PRE_DRAW_PRIMITIVE_SCREEN_screen1:
            GFX_HGC_SetScreenState(HGC_SCREEN_STATE_DRAW_PRIMITIVE_SCREEN_screen1);
            break;
        case HGC_SCREEN_STATE_DRAW_PRIMITIVE_SCREEN_screen1:
            GFX_HGC_DrawScreen_Primitives(screen1);
            GFX_HGC_SetScreenState(HGC_SCREEN_STATE_POST_DRAW_PRIMITIVE_SCREEN_screen1);
            break;
        case HGC_SCREEN_STATE_POST_DRAW_PRIMITIVE_SCREEN_screen1:
            GFX_HGC_SetScreenState(HGC_SCREEN_STATE_DISPLAY_SCREEN_screen1);
            break;
        case HGC_SCREEN_STATE_DISPLAY_SCREEN_screen1:
            break;
        case HGC_SCREEN_STATE_SETUP_SCREEN_screen2:
            GFX_HGC_SetScreenState(HGC_SCREEN_STATE_PRE_DRAW_GOL_SCREEN_screen2);
            break;
        case HGC_SCREEN_STATE_PRE_DRAW_GOL_SCREEN_screen2:
            GFX_HGC_SetScreenState(HGC_SCREEN_STATE_DRAW_GOL_SCREEN_screen2);
            break;
        case HGC_SCREEN_STATE_DRAW_GOL_SCREEN_screen2:
            GFX_HGC_SetupScreen(screen2);
            GFX_HGC_DrawScreen_GOL(screen2);
            GFX_HGC_SetScreenState(HGC_SCREEN_STATE_POST_DRAW_GOL_SCREEN_screen2);
            break;
        case HGC_SCREEN_STATE_POST_DRAW_GOL_SCREEN_screen2:
            GFX_HGC_SetScreenState(HGC_SCREEN_STATE_PRE_DRAW_PRIMITIVE_SCREEN_screen2);
            break;
        case HGC_SCREEN_STATE_PRE_DRAW_PRIMITIVE_SCREEN_screen2:
            GFX_HGC_SetScreenState(HGC_SCREEN_STATE_DRAW_PRIMITIVE_SCREEN_screen2);
            break;
        case HGC_SCREEN_STATE_DRAW_PRIMITIVE_SCREEN_screen2:
            GFX_HGC_DrawScreen_Primitives(screen2);
            GFX_HGC_SetScreenState(HGC_SCREEN_STATE_POST_DRAW_PRIMITIVE_SCREEN_screen2);
            break;
        case HGC_SCREEN_STATE_POST_DRAW_PRIMITIVE_SCREEN_screen2:
            GFX_HGC_SetScreenState(HGC_SCREEN_STATE_DISPLAY_SCREEN_screen2);
            break;
        case HGC_SCREEN_STATE_DISPLAY_SCREEN_screen2:
            break;
        case HGC_SCREEN_STATE_SETUP_SCREEN_screen3:
            GFX_HGC_SetScreenState(HGC_SCREEN_STATE_PRE_DRAW_GOL_SCREEN_screen3);
            break;
        case HGC_SCREEN_STATE_PRE_DRAW_GOL_SCREEN_screen3:
            GFX_HGC_SetScreenState(HGC_SCREEN_STATE_DRAW_GOL_SCREEN_screen3);
            break;
        case HGC_SCREEN_STATE_DRAW_GOL_SCREEN_screen3:
            GFX_HGC_SetupScreen(screen3);
            GFX_HGC_DrawScreen_GOL(screen3);
            GFX_HGC_SetScreenState(HGC_SCREEN_STATE_POST_DRAW_GOL_SCREEN_screen3);
            break;
        case HGC_SCREEN_STATE_POST_DRAW_GOL_SCREEN_screen3:
            GFX_HGC_SetScreenState(HGC_SCREEN_STATE_PRE_DRAW_PRIMITIVE_SCREEN_screen3);
            break;
        case HGC_SCREEN_STATE_PRE_DRAW_PRIMITIVE_SCREEN_screen3:
            GFX_HGC_SetScreenState(HGC_SCREEN_STATE_DRAW_PRIMITIVE_SCREEN_screen3);
            break;
        case HGC_SCREEN_STATE_DRAW_PRIMITIVE_SCREEN_screen3:
            GFX_HGC_DrawScreen_Primitives(screen3);
            GFX_HGC_SetScreenState(HGC_SCREEN_STATE_POST_DRAW_PRIMITIVE_SCREEN_screen3);
            break;
        case HGC_SCREEN_STATE_POST_DRAW_PRIMITIVE_SCREEN_screen3:
            GFX_HGC_SetScreenState(HGC_SCREEN_STATE_DISPLAY_SCREEN_screen3);
            break;
        case HGC_SCREEN_STATE_DISPLAY_SCREEN_screen3:
            break;
        default:
            return true; // release drawing control to GOL by default
    }

    return true; // release drawing control to GOL
}

/******************************************************************************
  Function: 
    void GFX_HGC_SetupScreen( uint8_t  screenId )

  Remarks: 
    Clears current screen and starts a fresh screen with its background color
 */
void GFX_HGC_SetupScreen(uint8_t screenId)
{
    switch (screenId)
    {
        case screen1:
            GFX_ColorSet(GFX_INDEX_0, GFX_RGBConvert(0x00, 0x00, 0x00));
            GFX_ScreenClear(GFX_INDEX_0);

            GFX_GOL_ObjectListFree(GFX_INDEX_0); // free memory for the objects in the previous linked list and start new list
            break;
        case screen2:
            GFX_ColorSet(GFX_INDEX_0, GFX_RGBConvert(0x00, 0x00, 0x00));
            GFX_ScreenClear(GFX_INDEX_0);

            GFX_GOL_ObjectListFree(GFX_INDEX_0); // free memory for the objects in the previous linked list and start new list
            break;
        case screen3:
            GFX_ColorSet(GFX_INDEX_0, GFX_RGBConvert(0x00, 0x00, 0x00));
            GFX_ScreenClear(GFX_INDEX_0);

            GFX_GOL_ObjectListFree(GFX_INDEX_0); // free memory for the objects in the previous linked list and start new list
            break;
        default:
            break;
    }
}


/******************************************************************************
  Function: 
    bool GFX_HGC_ChangeScreen( uint8_t  screenId )

  Output: 
    Returns true if a screenId matches an existing screen identifier

  Remarks: 
    Can be called to initiate GFX Library to draw a new screen
 */
bool GFX_HGC_ChangeScreen(uint8_t screenId)
{
    switch (screenId)
    {
        case screen1:
            GFX_HGC_SetScreenState(HGC_SCREEN_STATE_SETUP_SCREEN_screen1);
            break;
        case screen2:
            GFX_HGC_SetScreenState(HGC_SCREEN_STATE_SETUP_SCREEN_screen2);
            break;
        case screen3:
            GFX_HGC_SetScreenState(HGC_SCREEN_STATE_SETUP_SCREEN_screen3);
            break;
        default:
            return false;
    }

    return true; // release drawing control to GOL
}

/******************************************************************************
  Function: 
    bool GFX_HGC_DrawScreen_GOL( uint8_t  screenId )

  Output: 
    Returns true if a screenId matches an existing screen identifier

  Remarks: 
    HGC-specified GFX GOL objects are drawn here, grouped by screen.
    The draw order is reverse Z-ordered.
 */
bool GFX_HGC_DrawScreen_GOL(uint8_t screenId)
{
    switch (screenId)
    {
        case screen1:
            break;
        case screen2:
            GFX_HGC_DrawItem(Picture1);
            GFX_HGC_DrawItem(StaticText1);
            break;
        case screen3:
            break;
        default:
            return false;
    }

    return true; // release drawing control to GOL
}


/******************************************************************************
  Function: 
    bool GFX_HGC_DrawScreen_Primitives( uint8_t  screenId )

  Output:
    Returns true if a screenId matches an existing screen identifier

  Remarks: 
    HGC-specified GFX Primitives are drawn here, grouped by screen.
    GFX Primitives are drawn after GFX GOL Objects to make sure GFX GOL Objects
    do not cover GFX Primitives
 */
bool GFX_HGC_DrawScreen_Primitives(uint8_t screenId)
{
    switch (screenId)
    {
        case screen1:
            GFX_HGC_DrawItem(Circle1);
            GFX_HGC_DrawItem(Circle2);
            GFX_HGC_DrawItem(Circle3);
            GFX_HGC_DrawItem(Circle4);
            GFX_HGC_DrawItem(Circle5);
            GFX_HGC_DrawItem(Circle6);
            GFX_HGC_DrawItem(Circle7);
            GFX_HGC_DrawItem(Circle8);
            GFX_HGC_DrawItem(Circle9);
            GFX_HGC_DrawItem(Circle10);
            GFX_HGC_DrawItem(Line1);
            GFX_HGC_DrawItem(Line2);
            GFX_HGC_DrawItem(Line3);
            GFX_HGC_DrawItem(Line4);
            GFX_HGC_DrawItem(Line5);
            GFX_HGC_DrawItem(Line6);
            GFX_HGC_DrawItem(Line7);
            GFX_HGC_DrawItem(Line8);
            GFX_HGC_DrawItem(Line9);
            GFX_HGC_DrawItem(Line10);
            GFX_HGC_DrawItem(Line11);
            break;
        case screen2:
            break;
        case screen3:
            GFX_HGC_DrawItem(Rectangle2);
            GFX_HGC_DrawItem(Rectangle3);
            GFX_HGC_DrawItem(Rectangle1);
            GFX_HGC_DrawItem(Rectangle4);
            GFX_HGC_DrawItem(Rectangle5);
            break;
        default:
            return true;
    }

    return true; // release drawing control to GOL
}


/******************************************************************************
  Function: 
    bool GFX_HGC_DrawItem(int itemId)

  Output:
    Returns true if a itemId matches an existing item identifier

  Remarks: 
    Every item specified in every screen in HGC is listed in this function
 */
bool GFX_HGC_DrawItem(int itemId)
{
    switch(itemId)
    {
    case StaticText1:
        hgcObj.pStaticText1Obj = GFX_GOL_StaticTextCreate
                (
                 GFX_INDEX_0,
                 StaticText1,      // button ID
                 GFX_STATICTEXT_LEFT_0,    // left
                 GFX_STATICTEXT_TOP_0,     // top
                 GFX_STATICTEXT_RIGHT_0,   // right
                 GFX_STATICTEXT_BOTTOM_0,  // bottom
                 GFX_STATICTEXT_STATE_0,   // state
                 (GFX_XCHAR*)staticTextStr_0,    // text
                 GFX_STATICTEXT_ALIGNMENT_0,       //alignment
                 GFX_STATICTEXT_SCHEME_0
                 ); // use alternate scheme
        break;
    case Picture1:
        hgcObj.pPicture1Obj = GFX_GOL_PictureControlCreate
                (
                 GFX_INDEX_0,
                 Picture1,      // picture ID
                 GFX_PICTURE_LEFT_0,    // left
                 GFX_PICTURE_TOP_0,     // top
                 GFX_PICTURE_RIGHT_0,   // right                                 
                 GFX_PICTURE_BOTTOM_0,  // bottom
                                 GFX_PICTURE_STATE_0,   // state                 
                 GFX_PICTURE_SCALE_0,     // scale
                 (GFX_RESOURCE_HDR*)&flower16bit,    // bitmap
                 GFX_PICTURE_SCHEME_0
                 );
        break;
                case Line11:
                {
                        GFX_ColorSet(GFX_INDEX_0, GFX_RGBConvert(0xF8, 0xFC, 0xF8));
                        GFX_LineStyleSet(GFX_INDEX_0, GFX_LINE_STYLE_THIN_SOLID);
                        GFX_LineDraw(GFX_INDEX_0,
                                                 240/6*5,   //267,  // p1x
                                                 0,  // p1y
                                                 240/6, //53,  // p2x
                                                 319);  //239); // p2y
                        break;
                }               
                case Line10:
                {
                        GFX_ColorSet(GFX_INDEX_0, GFX_RGBConvert(0xF8, 0xFC, 0xF8));
                        GFX_LineStyleSet(GFX_INDEX_0, GFX_LINE_STYLE_THIN_SOLID);
                        GFX_LineDraw(GFX_INDEX_0,
                                                 240/6*4,   //214,  // p1x
                                                 0,  // p1y
                                                 240/6*2,   //106,  // p2x
                                                 319);  //239); // p2y
                        break;
                }               
                case Line9:
                {
                        GFX_ColorSet(GFX_INDEX_0, GFX_RGBConvert(0xF8, 0xFC, 0xF8));
                        GFX_LineStyleSet(GFX_INDEX_0, GFX_LINE_STYLE_THIN_SOLID);
                        GFX_LineDraw(GFX_INDEX_0,
                                                 240/6*2,   //106,  // p1x
                                                 0,  // p1y
                                                 240/6*4,   //214,  // p2x
                                                 319);  //239); // p2y
                        break;
                }               
                case Line8:
                {
                        GFX_ColorSet(GFX_INDEX_0, GFX_RGBConvert(0xF8, 0xFC, 0xF8));
                        GFX_LineStyleSet(GFX_INDEX_0, GFX_LINE_STYLE_THIN_SOLID);
                        GFX_LineDraw(GFX_INDEX_0,
                                                 240/6, //53,  // p1x
                                                 0,  // p1y
                                                 240/6*5,   //267,  // p2x
                                                 319);  //239); // p2y
                        break;
                }               
                case Line7:
                {
                        GFX_ColorSet(GFX_INDEX_0, GFX_RGBConvert(0xF8, 0xFC, 0xF8));
                        GFX_LineStyleSet(GFX_INDEX_0, GFX_LINE_STYLE_THIN_SOLID);
                        GFX_LineDraw(GFX_INDEX_0,
                                                120,    // 160,  // p1x
                                                 0,  // p1y
                                                120,    // 160,  // p2x
                                                319);    // 239); // p2y
                        break;
                }               
                case Line6:
                {
                        GFX_ColorSet(GFX_INDEX_0, GFX_RGBConvert(0xF8, 0xFC, 0xF8));
                        GFX_LineStyleSet(GFX_INDEX_0, GFX_LINE_STYLE_THIN_SOLID);
                        GFX_LineDraw(GFX_INDEX_0,
                                                 0,  // p1x
                                                 319,   //239,  // p1y
                                                 239,   //319,  // p2x
                                                 0); // p2y
                        break;
                }               
                case Line5:
                {
                        GFX_ColorSet(GFX_INDEX_0, GFX_RGBConvert(0xF8, 0xFC, 0xF8));
                        GFX_LineStyleSet(GFX_INDEX_0, GFX_LINE_STYLE_THIN_SOLID);
                        GFX_LineDraw(GFX_INDEX_0,
                                                 0,  // p1x
                                                 0,  // p1y
                                                 239,   //319,  // p2x
                                                 319);   //239); // p2y
                        break;
                }               
                case Line4: //LIGHT GREEN
                {
                        GFX_ColorSet(GFX_INDEX_0, GFX_RGBConvert(0x00, 0xFC, 0x00));
                        GFX_LineStyleSet(GFX_INDEX_0, GFX_LINE_STYLE_THIN_SOLID);
                        GFX_LineDraw(GFX_INDEX_0,
                                                 239,   //319,  // p1x
                                                 0,  // p1y
                                                 239,   //319,  // p2x
                                                 319);  //239); // p2y
                        break;
                }               
                case Line3: //YELLOW
                {
                        GFX_ColorSet(GFX_INDEX_0, GFX_RGBConvert(0xF8, 0xFC, 0x00));
                        GFX_LineStyleSet(GFX_INDEX_0, GFX_LINE_STYLE_THIN_SOLID);
                        GFX_LineDraw(GFX_INDEX_0,
                                                 0,  // p1x
                                                 0,  // p1y
                                                 0,  // p2x
                                                 319);  //239); // p2y
                        break;
                }               
                case Line2: //BLUE
                {
                        GFX_ColorSet(GFX_INDEX_0, GFX_RGBConvert(0x00, 0x00, 0xF8));
                        GFX_LineStyleSet(GFX_INDEX_0, GFX_LINE_STYLE_THIN_SOLID);
                        GFX_LineDraw(GFX_INDEX_0,
                                                 0,  // p1x
                                                 319,   //239,  // p1y
                                                 239,   //319,  // p2x
                                                 319);  //239); // p2y
                        break;
                }               
                case Line1: //RED
                {
                        GFX_ColorSet(GFX_INDEX_0, GFX_RGBConvert(0xF8, 0x00, 0x00));
                        GFX_LineStyleSet(GFX_INDEX_0, GFX_LINE_STYLE_THIN_SOLID);
                        GFX_LineDraw(GFX_INDEX_0,
                                                 0,  // p1x
                                                 0,  // p1y
                                                 239,   //319,  // p2x
                                                 0); // p2y
                        break;
                }               
                case Rectangle5:
                {
                        GFX_ColorSet(GFX_INDEX_0, GFX_RGBConvert(0x00, 0x00, 0xF8));
                        GFX_LineStyleSet(GFX_INDEX_0, GFX_LINE_STYLE_THIN_SOLID);
                        GFX_RectangleDraw(GFX_INDEX_0,
                                                          65-40,  // p1x
                                                          30+40,  // p1y
                                                          255-40,  // p2x
                                                          210+40); // p2y
                        
                        break;
                }       
                case Rectangle4:
                {
                        GFX_ColorSet(GFX_INDEX_0, GFX_RGBConvert(0x00, 0x00, 0xF8));
                        GFX_LineStyleSet(GFX_INDEX_0, GFX_LINE_STYLE_THIN_SOLID);
                        GFX_RectangleDraw(GFX_INDEX_0,
                                                          80-40,  // p1x
                                                          45+40,  // p1y
                                                          240-40,  // p2x
                                                          195+40); // p2y
                        
                        break;
                }       
                case Rectangle1:
                {
                        GFX_FillStyleSet(GFX_INDEX_0, GFX_FILL_STYLE_ALPHA_COLOR);
                        GFX_ColorSet(GFX_INDEX_0, GFX_RGBConvert(0xF8, 0x00, 0x00));
                        GFX_AlphaBlendingValueSet(GFX_INDEX_0, 100);
                        GFX_RectangleFillDraw(GFX_INDEX_0,
                                                                  125-40,  // p1x
                                                                  90+40,  // p1y
                                                                  195-40,  // p2x
                                                                  150+40); // p2y
                        
                        GFX_ColorSet(GFX_INDEX_0, GFX_RGBConvert(0xF8, 0x00, 0x00));
                        GFX_LineStyleSet(GFX_INDEX_0, GFX_LINE_STYLE_THIN_SOLID);
                        GFX_RectangleDraw(GFX_INDEX_0,
                                                          125-40,  // p1x
                                                          90+40,  // p1y
                                                          195-40,  // p2x
                                                          150+40); // p2y
                        
                        break;
                }       
                case Rectangle3:
                {
                        GFX_FillStyleSet(GFX_INDEX_0, GFX_FILL_STYLE_COLOR);
                        GFX_ColorSet(GFX_INDEX_0, GFX_RGBConvert(0x00, 0xFC, 0x00));
                        GFX_RectangleFillDraw(GFX_INDEX_0,
                                                                  110-40,  // p1x
                                                                  75+40,  // p1y
                                                                  210-40,  // p2x
                                                                  165+40); // p2y
                        
                        GFX_ColorSet(GFX_INDEX_0, GFX_RGBConvert(0x00, 0xFC, 0x00));
                        GFX_LineStyleSet(GFX_INDEX_0, GFX_LINE_STYLE_THIN_SOLID);
                        GFX_RectangleDraw(GFX_INDEX_0,
                                                          110-40,  // p1x
                                                          75+40,  // p1y
                                                          210-40,  // p2x
                                                          165+40); // p2y
                        
                        break;
                }       
                case Rectangle2:
                {
                        GFX_FillStyleSet(GFX_INDEX_0, GFX_FILL_STYLE_COLOR);
                        GFX_ColorSet(GFX_INDEX_0, GFX_RGBConvert(0x00, 0x00, 0xF8));
                        GFX_RectangleFillDraw(GFX_INDEX_0,
                                                                  95-40,  // p1x
                                                                  60+40,  // p1y
                                                                  225-40,  // p2x
                                                                  180+40); // p2y
                        
                        GFX_ColorSet(GFX_INDEX_0, GFX_RGBConvert(0x00, 0x00, 0xF8));
                        GFX_LineStyleSet(GFX_INDEX_0, GFX_LINE_STYLE_THIN_SOLID);
                        GFX_RectangleDraw(GFX_INDEX_0,
                                                          95-40,  // p1x
                                                          60+40,  // p1y
                                                          225-40,  // p2x
                                                          180+40); // p2y
                        
                        break;
                }       
                case Circle10:
                {
                        GFX_ColorSet(GFX_INDEX_0,GFX_RGBConvert(0xF8, 0x00, 0x00));
                        GFX_LineStyleSet(GFX_INDEX_0, GFX_LINE_STYLE_THIN_SOLID);
                        GFX_CircleDraw(GFX_INDEX_0,
                                                   120, //160, // p1x
                                                   160, //120, // p1y
                                                   3); // radius
                                                   
                        break;
                }       
                case Circle9:
                {
                        GFX_ColorSet(GFX_INDEX_0,GFX_RGBConvert(0xF8, 0x00, 0x00));
                        GFX_LineStyleSet(GFX_INDEX_0, GFX_LINE_STYLE_THIN_SOLID);
                        GFX_CircleDraw(GFX_INDEX_0,
                                                   120, //160, // p1x
                                                   160, //120, // p1y
                                                   16); // radius
                                                   
                        break;
                }       
                case Circle8:
                {
                        GFX_ColorSet(GFX_INDEX_0,GFX_RGBConvert(0xF8, 0x00, 0x00));
                        GFX_LineStyleSet(GFX_INDEX_0, GFX_LINE_STYLE_THIN_SOLID);
                        GFX_CircleDraw(GFX_INDEX_0,
                                                   120, //160, // p1x
                                                   160, //120, // p1y
                                                   29); // radius
                                                   
                        break;
                }       
                case Circle7:
                {
                        GFX_ColorSet(GFX_INDEX_0,GFX_RGBConvert(0xF8, 0x00, 0x00));
                        GFX_LineStyleSet(GFX_INDEX_0, GFX_LINE_STYLE_THIN_SOLID);
                        GFX_CircleDraw(GFX_INDEX_0,
                                                   120, //160, // p1x
                                                   160, //120, // p1y
                                                   42); // radius
                                                   
                        break;
                }       
                case Circle6:
                {
                        GFX_ColorSet(GFX_INDEX_0,GFX_RGBConvert(0xF8, 0x00, 0x00));
                        GFX_LineStyleSet(GFX_INDEX_0, GFX_LINE_STYLE_THIN_SOLID);
                        GFX_CircleDraw(GFX_INDEX_0,
                                                   120, //160, // p1x
                                                   160, //120, // p1y
                                                   55); // radius
                                                   
                        break;
                }       
                case Circle5:
                {
                        GFX_ColorSet(GFX_INDEX_0,GFX_RGBConvert(0xF8, 0x00, 0x00));
                        GFX_LineStyleSet(GFX_INDEX_0, GFX_LINE_STYLE_THIN_SOLID);
                        GFX_CircleDraw(GFX_INDEX_0,
                                                   120, //160, // p1x
                                                   160, //120, // p1y
                                                   68); // radius
                                                   
                        break;
                }       
                case Circle4:
                {
                        GFX_ColorSet(GFX_INDEX_0,GFX_RGBConvert(0xF8, 0x00, 0x00));
                        GFX_LineStyleSet(GFX_INDEX_0, GFX_LINE_STYLE_THIN_SOLID);
                        GFX_CircleDraw(GFX_INDEX_0,
                                                   120, //160, // p1x
                                                   160, //120, // p1y
                                                   81); // radius
                                                   
                        break;
                }       
                case Circle3:
                {
                        GFX_ColorSet(GFX_INDEX_0,GFX_RGBConvert(0xF8, 0x00, 0x00));
                        GFX_LineStyleSet(GFX_INDEX_0, GFX_LINE_STYLE_THIN_SOLID);
                        GFX_CircleDraw(GFX_INDEX_0,
                                                   120, //160, // p1x
                                                   160, //120, // p1y
                                                   94); // radius
                                                   
                        break;
                }       
                case Circle2:
                {
                        GFX_ColorSet(GFX_INDEX_0,GFX_RGBConvert(0xF8, 0x00, 0x00));
                        GFX_LineStyleSet(GFX_INDEX_0, GFX_LINE_STYLE_THIN_SOLID);
                        GFX_CircleDraw(GFX_INDEX_0,
                                                   120, //160, // p1x
                                                   160, //120, // p1y
                                                   107); // radius
                                                   
                        break;
                }       
                case Circle1:
                {
                        GFX_ColorSet(GFX_INDEX_0,GFX_RGBConvert(0xF8, 0x00, 0x00));
                        GFX_LineStyleSet(GFX_INDEX_0, GFX_LINE_STYLE_THIN_SOLID);
                        GFX_CircleDraw(GFX_INDEX_0,
                                                   120, //160, // p1x
                                                   160, //120, // p1y
                                                   120); // radius
                                                   
                        break;
                }       
        default:
                return false; // process by default
    }

    return true;
}

/******************************************************************************
  Function: 
    bool GFX_HGC_MsgStaticTexts(uint16_t objMsg, GFX_GOL_OBJ_HEADER *pObj)

  Output:
    Returns true if a Object ID matches an existing item identifier

  Remarks: 
    Handles GFX GOL Static Text events
 */
bool GFX_HGC_MsgStaticTexts(uint16_t objMsg, GFX_GOL_OBJ_HEADER *pObj)
{
    switch (GFX_GOL_ObjectIDGet(pObj))
    {
        default:
            return false; // default false as it is not processed
    }    
}

/******************************************************************************
  Function: 
    bool GFX_HGC_MsgPictures(uint16_t objMsg, GFX_GOL_OBJ_HEADER *pObj)

  Output:
    Returns true if a Object ID matches an existing item identifier

  Remarks: 
    Handles GFX GOL Picture Control events
 */
bool GFX_HGC_MsgPictures(uint16_t objMsg, GFX_GOL_OBJ_HEADER *pObj)
{
    switch (GFX_GOL_ObjectIDGet(pObj))
    {
        default:
            return false; // default false as it is not processed
    }    
}

 <動作結果>

1. ピクチャー

液晶画面モード  液晶INT022の画面 
 画面@  
 画面A  
 画面B  



2.. 動画 ----> YouTube



 マイクロチップ デモソフト”Primitive”  at PIC32MZ + INT024 

   
  <試作品仕様>
   ・ Harmonyのグラフィックライブラリのサンプルデモソフトとして マイクロチップから提供されている
      ”Primitive"(C:\microchip\harmony\v1_05\apps\gfx\primitive)を
     下記ハードウェアで実行する
      @ PIC: PIC32MZ2048EFH100
      A 液晶: (株)ディスプレーテック INT024 QVGA(320 x240)、2.4インチ
   
   ・ 開発環境  Harmony ver.1.06、  XC32 ver.1.40、  MPLABX 3.15  PIC32MZ2048EFH  revison 1
  

  <試作品回路図>(→回路図のPDFファイル





<試作品外観>下記の写真には上記回路図にはない、また本テーマと関係のない部品が多々写っています



          

   <プログラム例>

//以下、main.c
//------------------------------------------------------------------------------------------
/*******************************************************************************
  MPLAB Harmony Project Main Source File

  Company:
    Microchip Technology Inc.
  
  File Name:
    main.c

  Summary:
    This file contains the "main" function for an MPLAB Harmony project.

  Description:
    This file contains the "main" function for an MPLAB Harmony project.  The
    "main" function calls the "SYS_Initialize" function to initialize the state 
    machines of all MPLAB Harmony modules in the system and it calls the 
    "SYS_Tasks" function from within a system-wide "super" loop to maintain 
    their correct operation. These two functions are implemented in 
    configuration-specific files (usually "system_init.c" and "system_tasks.c")
    in a configuration-specific folder under the "src/system_config" folder 
    within this project's top-level folder.  An MPLAB Harmony project may have
    more than one configuration, each contained within it's own folder under
    the "system_config" folder.
 *******************************************************************************/

// DOM-IGNORE-BEGIN
/*******************************************************************************
Copyright (c) 2013-2014 released Microchip Technology Inc.  All rights reserved.

//Microchip licenses to you the right to use, modify, copy and distribute
Software only when embedded on a Microchip microcontroller or digital signal
controller that is integrated into your product or third party product
(pursuant to the sublicense terms in the accompanying license agreement).

You should refer to the license agreement accompanying this Software for
additional information regarding your rights and obligations.

SOFTWARE AND DOCUMENTATION ARE PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND,
EITHER EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION, ANY WARRANTY OF
MERCHANTABILITY, TITLE, NON-INFRINGEMENT AND FITNESS FOR A PARTICULAR PURPOSE.
IN NO EVENT SHALL MICROCHIP OR ITS LICENSORS BE LIABLE OR OBLIGATED UNDER
CONTRACT, NEGLIGENCE, STRICT LIABILITY, CONTRIBUTION, BREACH OF WARRANTY, OR
OTHER LEGAL EQUITABLE THEORY ANY DIRECT OR INDIRECT DAMAGES OR EXPENSES
INCLUDING BUT NOT LIMITED TO ANY INCIDENTAL, SPECIAL, INDIRECT, PUNITIVE OR
CONSEQUENTIAL DAMAGES, LOST PROFITS OR LOST DATA, COST OF PROCUREMENT OF
SUBSTITUTE GOODS, TECHNOLOGY, SERVICES, OR ANY CLAIMS BY THIRD PARTIES
(INCLUDING BUT NOT LIMITED TO ANY DEFENSE THEREOF), OR OTHER SIMILAR COSTS.
 *******************************************************************************/
// DOM-IGNORE-END


// *****************************************************************************
// *****************************************************************************
// Section: Included Files
// *****************************************************************************
// *****************************************************************************

#include <stddef.h>                     // Defines NULL
#include <stdbool.h>                    // Defines true
#include <stdlib.h>                     // Defines EXIT_FAILURE
#include "system/common/sys_module.h"   // SYS function prototypes


// *****************************************************************************
// *****************************************************************************
// Section: Main Entry Point
// *****************************************************************************
// *****************************************************************************

int main ( void )
{
    /* Initialize all MPLAB Harmony modules, including application(s). */
    SYS_Initialize ( NULL );


    while ( true )
    {
        /* Maintain state machines of all polled MPLAB Harmony modules. */
        SYS_Tasks ( );

    }

    /* Execution should not come here during normal operation */

    return ( EXIT_FAILURE );
}


/*******************************************************************************
 End of File
*/






//以下、app.c
//------------------------------------------------------------------------------------------



/*******************************************************************************
  MPLAB Harmony Application Source File
  
  Company:
    Microchip Technology Inc.
  
  File Name:
    app.c

  Summary:
    This file contains the source code for the MPLAB Harmony application.

  Description:
    This file contains the source code for the MPLAB Harmony application.  It 
    implements the logic of the application's state machine and it may call 
    API routines of other MPLAB Harmony modules in the system, such as drivers,
    system services, and middleware.  However, it does not call any of the
    system interfaces (such as the "Initialize" and "Tasks" functions) of any of
    the modules in the system or make any assumptions about when those functions
    are called.  That is the responsibility of the configuration-specific system
    files.
 *******************************************************************************/

// DOM-IGNORE-BEGIN
/*******************************************************************************
Copyright (c) 2013-2014 released Microchip Technology Inc.  All rights reserved.

Microchip licenses to you the right to use, modify, copy and distribute
Software only when embedded on a Microchip microcontroller or digital signal
controller that is integrated into your product or third party product
(pursuant to the sublicense terms in the accompanying license agreement).

You should refer to the license agreement accompanying this Software for
additional information regarding your rights and obligations.

SOFTWARE AND DOCUMENTATION ARE PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND,
EITHER EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION, ANY WARRANTY OF
MERCHANTABILITY, TITLE, NON-INFRINGEMENT AND FITNESS FOR A PARTICULAR PURPOSE.
IN NO EVENT SHALL MICROCHIP OR ITS LICENSORS BE LIABLE OR OBLIGATED UNDER
CONTRACT, NEGLIGENCE, STRICT LIABILITY, CONTRIBUTION, BREACH OF WARRANTY, OR
OTHER LEGAL EQUITABLE THEORY ANY DIRECT OR INDIRECT DAMAGES OR EXPENSES
INCLUDING BUT NOT LIMITED TO ANY INCIDENTAL, SPECIAL, INDIRECT, PUNITIVE OR
CONSEQUENTIAL DAMAGES, LOST PROFITS OR LOST DATA, COST OF PROCUREMENT OF
SUBSTITUTE GOODS, TECHNOLOGY, SERVICES, OR ANY CLAIMS BY THIRD PARTIES
(INCLUDING BUT NOT LIMITED TO ANY DEFENSE THEREOF), OR OTHER SIMILAR COSTS.
 *******************************************************************************/
// DOM-IGNORE-END


// *****************************************************************************
// *****************************************************************************
// Section: Included Files 
// *****************************************************************************
// *****************************************************************************

#include "app.h"
#include "1lcd_lib_C32.h"


int delay_Clock = 200000000;   //200MHz

void delay_us(volatile unsigned int usec)        //1μsec遅延
{
        volatile  int count;

        count = (int)(delay_Clock/20000000)*usec;


        do      //実測 at 200MH (Clock=200000000)
        {       //delay_us(1000):1000.4μsec  delay_us(100):100.6μsec  delay_us(10):10.5μsec  delay_us(1):1.5μsec
                asm("NOP"); asm("NOP"); asm("NOP"); asm("NOP"); asm("NOP");asm("NOP");
                asm("NOP"); asm("NOP"); asm("NOP"); asm("NOP"); asm("NOP"); asm("NOP");

                count--;
        }while(count != 0);


}

void delay_ms(volatile unsigned int msec)        //1msec遅延
{
        volatile unsigned int i;         //実測:at200MH (Clock=200000000)//delay_ms(1): 1.0006msec   delay_ms(100):100.04msec

        for(i=0; i<msec; i++)
        delay_us(1000);
}



// *****************************************************************************
// *****************************************************************************
// Section: Global Data Definitions
// *****************************************************************************
// *****************************************************************************

// *****************************************************************************
/* Application Data

  Summary:
    Holds application data

  Description:
    This structure holds the application's data.

  Remarks:
    This structure should be initialized by the APP_Initialize function.
    
    Application strings and buffers are be defined outside this structure.
*/

APP_DATA appData;





// *****************************************************************************
// *****************************************************************************
// Section: MACROS
// *****************************************************************************
// *****************************************************************************
#define MIN(x,y)                ((x > y)? y: x)
#define APP_SCREEN_DELAY_MS         (1000)
// *****************************************************************************
// *****************************************************************************
// Section: Global Variable Definitions
// *****************************************************************************
// *****************************************************************************

// *****************************************************************************
// *****************************************************************************
// Section: Application Local Routines
// *****************************************************************************
void APP_TMR_DelayMS ( unsigned int delayMs );


// *****************************************************************************
// *****************************************************************************
// Section: Application Callback Functions
// *****************************************************************************
// *****************************************************************************

/* TODO:  Add any necessary callback funtions.
*/

// *****************************************************************************
// *****************************************************************************
// Section: Application Local Functions
// *****************************************************************************
// *****************************************************************************

/* TODO:  Add any necessary local functions.
*/


// *****************************************************************************
// *****************************************************************************
// Section: Application Initialization and State Machine Functions
// *****************************************************************************
// *****************************************************************************

/*******************************************************************************
  Function:
    void APP_Initialize ( void )

  Remarks:
    See prototype in app.h.
 */

void APP_Initialize ( void )
{
    /* Place the App state machine in its initial state. */
    appData.state = APP_STATE_INIT;
    
    /* TODO: Initialize your application's state machine and other
     * parameters.
     */
}


/******************************************************************************
  Function:
    void APP_Tasks ( void )

  Remarks:
    See prototype in app.h.
 */

void APP_Tasks ( void )
{
    /* Check the application's current state. */
    switch ( appData.state )
    {
        /* Application's initial state. */
        case APP_STATE_INIT:
        {
            appData.state = APP_HGC_SCREEN1_DRAW;
            break;
        }
        
        case APP_HGC_SCREEN1_DRAW:
        {
            if(hgcObj.screenState != HGC_SCREEN_STATE_DISPLAY_SCREEN_screen1)
                return;
            
            GFX_HGC_ChangeScreen(screen2);
            APP_TMR_DelayMS(1000);
            appData.state = APP_HGC_SCREEN2_DRAW;
            
            break;
        }    

        case APP_HGC_SCREEN2_DRAW:
        {
            if(hgcObj.screenState != HGC_SCREEN_STATE_DISPLAY_SCREEN_screen2)
                return;
            
            GFX_HGC_ChangeScreen(screen3);
            APP_TMR_DelayMS(1000);
            appData.state = APP_HGC_SCREEN3_DRAW;
            break;
        }
        
        case APP_HGC_SCREEN3_DRAW:
        {
            if(hgcObj.screenState != HGC_SCREEN_STATE_DISPLAY_SCREEN_screen3)
                return;
            
            GFX_HGC_ChangeScreen(screen1);
            APP_TMR_DelayMS(1000);
            appData.state = APP_HGC_SCREEN1_DRAW;
            break;
        }    

        /* The default state should never be executed. */
        default:
        {
            /* TODO: Handle error in application's state machine. */
            break;
        }
    }
}

void APP_TMR_DelayMS ( unsigned int delayMs )
{
    if(delayMs)
    {
        uint32_t sysClk = SYS_CLK_FREQ;
        uint32_t t0;
        t0 = _CP0_GET_COUNT();
        while (_CP0_GET_COUNT() - t0 < (sysClk/2000)*delayMs);
    }
}

/*******************************************************************************
 End of File
 */









//以下、system_init.c
//---------------------------------------------------------------------------------
/*******************************************************************************
  System Initialization File

  File Name:
    system_init.c

  Summary:
    This file contains source code necessary to initialize the system.

  Description:
    This file contains source code necessary to initialize the system.  It
    implements the "SYS_Initialize" function, defines the configuration bits, 
    and allocates any necessary global system resources, such as the 
    sysObj structure that contains the object handles to all the MPLAB Harmony 
    module objects in the system.
 *******************************************************************************/

// DOM-IGNORE-BEGIN
/*******************************************************************************
Copyright (c) 2013-2015 released Microchip Technology Inc.  All rights reserved.

Microchip licenses to you the right to use, modify, copy and distribute
Software only when embedded on a Microchip microcontroller or digital signal
controller that is integrated into your product or third party product
(pursuant to the sublicense terms in the accompanying license agreement).

You should refer to the license agreement accompanying this Software for
additional information regarding your rights and obligations.

SOFTWARE AND DOCUMENTATION ARE PROVIDED AS IS WITHOUT WARRANTY OF ANY KIND,
EITHER EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION, ANY WARRANTY OF
MERCHANTABILITY, TITLE, NON-INFRINGEMENT AND FITNESS FOR A PARTICULAR PURPOSE.
IN NO EVENT SHALL MICROCHIP OR ITS LICENSORS BE LIABLE OR OBLIGATED UNDER
CONTRACT, NEGLIGENCE, STRICT LIABILITY, CONTRIBUTION, BREACH OF WARRANTY, OR
OTHER LEGAL EQUITABLE THEORY ANY DIRECT OR INDIRECT DAMAGES OR EXPENSES
INCLUDING BUT NOT LIMITED TO ANY INCIDENTAL, SPECIAL, INDIRECT, PUNITIVE OR
CONSEQUENTIAL DAMAGES, LOST PROFITS OR LOST DATA, COST OF PROCUREMENT OF
SUBSTITUTE GOODS, TECHNOLOGY, SERVICES, OR ANY CLAIMS BY THIRD PARTIES
(INCLUDING BUT NOT LIMITED TO ANY DEFENSE THEREOF), OR OTHER SIMILAR COSTS.
 *******************************************************************************/
// DOM-IGNORE-END


// *****************************************************************************
// *****************************************************************************
// Section: Included Files
// *****************************************************************************
// *****************************************************************************

#include "system_config.h"
#include "system_definitions.h"


// ****************************************************************************
// ****************************************************************************
// Section: Configuration Bits
// ****************************************************************************
// ****************************************************************************
// <editor-fold defaultstate="collapsed" desc="Configuration Bits">

/*** DEVCFG0 ***/

#pragma config DEBUG =      OFF
#pragma config JTAGEN =     OFF
#pragma config ICESEL =     ICS_PGx1
#pragma config TRCEN =      OFF
#pragma config BOOTISA =    MIPS32
#pragma config FECCCON =    OFF_UNLOCKED
#pragma config FSLEEP =     OFF
#pragma config DBGPER =     PG_ALL
#pragma config EJTAGBEN =   NORMAL
#pragma config CP =         OFF

/*** DEVCFG1 ***/

#pragma config FNOSC =      SPLL
#pragma config DMTINTV =    WIN_127_128
#pragma config FSOSCEN =    OFF
#pragma config IESO =       OFF
#pragma config POSCMOD =    EC
#pragma config OSCIOFNC =   OFF
#pragma config FCKSM =      CSECME
#pragma config WDTPS =      PS1048576
#pragma config WDTSPGM =    STOP
#pragma config FWDTEN =     OFF
#pragma config WINDIS =     NORMAL
#pragma config FWDTWINSZ =  WINSZ_25
#pragma config DMTCNT =     DMT31
#pragma config FDMTEN =     OFF

/*** DEVCFG2 ***/

#pragma config FPLLIDIV =   DIV_3
#pragma config FPLLRNG =    RANGE_5_10_MHZ

#pragma config FPLLICLK =   PLL_POSC
#pragma config FPLLMULT =   MUL_50
#pragma config FPLLODIV =   DIV_2
#pragma config UPLLFSEL =   FREQ_24MHZ
//#pragma config UPLLEN =     ON

/*** DEVCFG3 ***/

#pragma config USERID =     0xffff
#pragma config FMIIEN =     ON
#pragma config FETHIO =     ON
#pragma config PGL1WAY =    ON
#pragma config PMDL1WAY =   ON
#pragma config IOL1WAY =    ON
#pragma config FUSBIDIO =   ON

/*** BF1SEQ0 ***/

#pragma config TSEQ =       0xffff
#pragma config CSEQ =       0xffff
// </editor-fold>


// *****************************************************************************
// *****************************************************************************
// Section: Library/Stack Initialization Data
// *****************************************************************************
// *****************************************************************************



// *****************************************************************************
// *****************************************************************************
// Section: Driver Initialization Data
// *****************************************************************************
// *****************************************************************************


// </editor-fold>

DRV_GFX_INIT drvGfxInit =
{
    .orientation             = DISP_ORIENTATION,
    .horizontalResolution    = DISP_HOR_RESOLUTION,
    .verticalResolution      = DISP_VER_RESOLUTION,
    
/*
    .dataWidth               = DISP_DATA_WIDTH,
    .horizontalPulseWidth    = DISP_HOR_PULSE_WIDTH,
    .horizontalBackPorch     = DISP_HOR_BACK_PORCH,
    .horizontalFrontPorch    = DISP_HOR_FRONT_PORCH,
    .verticalPulseWidth      = DISP_VER_PULSE_WIDTH,
    .verticalBackPorch       = DISP_VER_BACK_PORCH,
    .verticalFrontPorch      = DISP_VER_FRONT_PORCH,
    .logicShift              = DISP_INV_LSHIFT,
    .LCDType                 = 1,
    .colorType               = 0,
    .TCON_Init               = TCON_MODULE,
 */ 
    
};





// *****************************************************************************
// *****************************************************************************
// Section: System Data
// *****************************************************************************
// *****************************************************************************

/* Structure to hold the object handles for the modules in the system. */
SYSTEM_OBJECTS sysObj;


// *****************************************************************************
// *****************************************************************************
// Section: Module Initialization Data
// *****************************************************************************
// *****************************************************************************

/*** GFX Initialization Data ***/

 const GFX_INIT gfxInit0 =
{
    .drvInitialize    = NULL,
    
   
    .drvOpen          = DRV_GFX_INT028_Open,
    .drvInterfaceSet  = DRV_GFX_INT028_InterfaceSet, 
  //  .drvOpen          = DRV_GFX_SSD1926_Open,
  //  .drvInterfaceSet  = DRV_GFX_SSD1926_InterfaceSet,
};

/*******************************************************************************
  Device Control System Service Initialization Data
  
  <editor-fold defaultstate="collapsed" 
  desc="Device Control System Service Initialization Data">
*/

const SYS_DEVCON_INIT sysDevconInit =
{
    .moduleInit = {0},
};

// </editor-fold>


// *****************************************************************************
// *****************************************************************************
// Section: Static Initialization Functions
// *****************************************************************************
// *****************************************************************************


// *****************************************************************************
// *****************************************************************************
// Section: System Initialization
// *****************************************************************************
// *****************************************************************************




void ys_PMP_Initialize(void)
{

    short pClockPeriod = 1000000000 / 100000000;
    
    // PMP setup
    PMMODE = 0;
    PMAEN = 0;
    PMCON = 0;
    PMMODEbits.MODE = 2;                // Intel 8080 master interface

    #if (PMP_DATA_SETUP_TIME == 0)
        PMMODEbits.WAITB = 0;
    #else
        if (PMP_DATA_SETUP_TIME <= pClockPeriod)
            PMMODEbits.WAITB = 0;
        else if (PMP_DATA_SETUP_TIME > pClockPeriod)
            PMMODEbits.WAITB = (PMP_DATA_SETUP_TIME / pClockPeriod) + 1;
    #endif

    #if (PMP_DATA_WAIT_TIME == 0)
        PMMODEbits.WAITM = 0;
    #else
        if (PMP_DATA_WAIT_TIME <= pClockPeriod)
            PMMODEbits.WAITM = 1;
        else if (PMP_DATA_WAIT_TIME > pClockPeriod)
            PMMODEbits.WAITM = (PMP_DATA_WAIT_TIME / pClockPeriod) + 1;
    #endif

    #if (PMP_DATA_HOLD_TIME == 0)
        PMMODEbits.WAITE = 0;
    #else
        if (PMP_DATA_HOLD_TIME <= pClockPeriod)
            PMMODEbits.WAITE = 0;
        else if (PMP_DATA_HOLD_TIME > pClockPeriod)
            PMMODEbits.WAITE = (PMP_DATA_HOLD_TIME / pClockPeriod) + 1;
    #endif

    #if defined(USE_16BIT_PMP)
    PMMODEbits.MODE16 = 1;              // 16 bit mode
    #elif defined(USE_8BIT_PMP)
    PMMODEbits.MODE16 = 0;              // 8 bit mode
    #endif

    PMCONbits.PTRDEN = 1;               // enable RD line
    PMCONbits.PTWREN = 1;               // enable WR line
    PMCONbits.PMPEN = 1;                // enable PMP

    delay_us(200);



}






/*******************************************************************************
  Function:
    void SYS_Initialize ( SYS_INIT_DATA *data )

  Summary:
    Initializes the board, services, drivers, application and other modules.

  Remarks:
    See prototype in system/common/sys_module.h.
 */

void SYS_Initialize ( void* data )
{
     
    
    /* Core Processor Initialization */
    SYS_CLK_Initialize( NULL );
    sysObj.sysDevcon = SYS_DEVCON_Initialize(SYS_DEVCON_INDEX_0, (SYS_MODULE_INIT*)&sysDevconInit);
    SYS_DEVCON_PerformanceConfig(SYS_CLK_SystemFrequencyGet());
    
    delay_ms(2000); //SYS_PORTS_Initialize(); ys_PMP_Initialize(); の前に設定のこと
    
    
    SYS_PORTS_Initialize();
    
     
   /*
    SYS_DEVCON_SystemUnlock();
    //PMP用ペリフェラルクロック低減 100MH → 25MHz
//    PB2DIVbits.PBDIV = 0b1111111;   //1/128
     PB2DIVbits.PBDIV = 0x03;  //PBCLK2 is SYSCLK divided by 4   //  PMP SPI 1/4 = 100MHz / 4 = 25MHz

    SYS_DEVCON_SystemLock();
  */  

    /* Initialize Drivers */

    /* Initialize System Services */

      delay_ms(500);  

//PMP 初期化 Initialize PMP0
    ys_PMP_Initialize();
//    DRV_PMP0_Initialize();
//    DRV_PMP0_ModeConfig();

    
//GFX グラフィック初期化
    DRV_GFX_INT028_Initialize(GFX_INDEX_0, (SYS_MODULE_INIT*)&drvGfxInit);
    //DRV_GFX_SSD1926_Initialize(GFX_INDEX_0, (SYS_MODULE_INIT*)&drvGfxInit);
   

    /* Initialize Middleware */

    sysObj.gfxObject0 = GFX_Initialize(GFX_INDEX_0, (SYS_MODULE_INIT *)&gfxInit0);  //GFX初期化
           
    /* Initialize the Application */
    APP_Initialize();
}


/*******************************************************************************
 End of File
*/






//以下、system_definitons.h
//----------------------------------------------------------------------------------

/*******************************************************************************
  System Definitions

  File Name:
    system_definitions.h

  Summary:
    MPLAB Harmony project system definitions.

  Description:
    This file contains the system-wide prototypes and definitions for an MPLAB
    Harmony project.
 *******************************************************************************/

//DOM-IGNORE-BEGIN
/*******************************************************************************
Copyright (c) 2013-2014 released Microchip Technology Inc.  All rights reserved.

Microchip licenses to you the right to use, modify, copy and distribute
Software only when embedded on a Microchip microcontroller or digital signal
controller that is integrated into your product or third party product
(pursuant to the sublicense terms in the accompanying license agreement).

You should refer to the license agreement accompanying this Software for
additional information regarding your rights and obligations.

SOFTWARE AND DOCUMENTATION ARE PROVIDED AS IS WITHOUT WARRANTY OF ANY KIND,
EITHER EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION, ANY WARRANTY OF
MERCHANTABILITY, TITLE, NON-INFRINGEMENT AND FITNESS FOR A PARTICULAR PURPOSE.
IN NO EVENT SHALL MICROCHIP OR ITS LICENSORS BE LIABLE OR OBLIGATED UNDER
CONTRACT, NEGLIGENCE, STRICT LIABILITY, CONTRIBUTION, BREACH OF WARRANTY, OR
OTHER LEGAL EQUITABLE THEORY ANY DIRECT OR INDIRECT DAMAGES OR EXPENSES
INCLUDING BUT NOT LIMITED TO ANY INCIDENTAL, SPECIAL, INDIRECT, PUNITIVE OR
CONSEQUENTIAL DAMAGES, LOST PROFITS OR LOST DATA, COST OF PROCUREMENT OF
SUBSTITUTE GOODS, TECHNOLOGY, SERVICES, OR ANY CLAIMS BY THIRD PARTIES
(INCLUDING BUT NOT LIMITED TO ANY DEFENSE THEREOF), OR OTHER SIMILAR COSTS.
 *******************************************************************************/
//DOM-IGNORE-END

#ifndef _SYS_DEFINITIONS_H
#define _SYS_DEFINITIONS_H


// *****************************************************************************
// *****************************************************************************
// Section: Included Files
// *****************************************************************************
// *****************************************************************************

#include <stdint.h>
#include <stddef.h>
#include <stdbool.h>
#include "system/common/sys_common.h"
#include "system/common/sys_module.h"
#include "system/clk/sys_clk.h"
#include "system/clk/sys_clk_static.h"
#include "system/devcon/sys_devcon.h"
#include "system/console/sys_console.h"

#include "framework/driver/pmp/drv_pmp_static.h"
#include "driver/tmr/drv_tmr_static.h"
#include "peripheral/int/plib_int.h"
#include "system/ports/sys_ports.h"
#include "gfx/gfx.h"
#include "gfx/gfx_gol.h"
#include "gfx/gfx_gol_scheme.h"


#include "drv_gfx_INT028_24_22.h"     //INT028, INT024, INT022用
//#include "driver/gfx/controller/ssd1926/drv_gfx_ssd1926.h"
#include "system/debug/sys_debug.h"
#include "system/command/sys_command.h"


#include "gfx_hgc_definitions.h"
#include "app.h"


// *****************************************************************************
// *****************************************************************************
// Section: Type Definitions
// *****************************************************************************
// *****************************************************************************

// *****************************************************************************
/* System Objects

  Summary:
    Structure holding the system's object handles

  Description:
    This structure contains the object handles for all objects in the
    MPLAB Harmony project's system configuration.

  Remarks:
    These handles are returned from the "Initialize" functions for each module
    and must be passed into the "Tasks" function for each module.
*/

typedef struct
{
    SYS_MODULE_OBJ  sysDevcon;
    SYS_MODULE_OBJ  gfxObject0;
    
} SYSTEM_OBJECTS;


// *****************************************************************************
// *****************************************************************************
// Section: extern declarations
// *****************************************************************************
// *****************************************************************************

extern SYSTEM_OBJECTS sysObj;

#endif /* _SYS_DEFINITIONS_H */
/*******************************************************************************
 End of File
*/




//以下、gfx_hgc_definitions.h
//--------------------------------------------------------------------------

/*******************************************************************************
  MPLAB Harmony Graphics Composer Generated Definitions Header

  File Name:
    gfx_hgc_definitions.h

  Summary:
    Build-time generated definitions header based on output by the MPLAB Harmony
    Graphics Composer.

  Description:
    Build-time generated definitions header based on output by the MPLAB Harmony
    Graphics Composer.

    Created with MPLAB Harmony Version 1.05
*******************************************************************************/

// DOM-IGNORE-BEGIN
/*******************************************************************************
Copyright (c) 2013-2014 released Microchip Technology Inc.  All rights reserved.

Microchip licenses to you the right to use, modify, copy and distribute
Software only when embedded on a Microchip microcontroller or digital signal
controller that is integrated into your product or third party product
(pursuant to the sublicense terms in the accompanying license agreement).

You should refer to the license agreement accompanying this Software for
additional information regarding your rights and obligations.

SOFTWARE AND DOCUMENTATION ARE PROVIDED AS IS WITHOUT WARRANTY OF ANY KIND,
EITHER EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION, ANY WARRANTY OF
MERCHANTABILITY, TITLE, NON-INFRINGEMENT AND FITNESS FOR A PARTICULAR PURPOSE.
IN NO EVENT SHALL MICROCHIP OR ITS LICENSORS BE LIABLE OR OBLIGATED UNDER
CONTRACT, NEGLIGENCE, STRICT LIABILITY, CONTRIBUTION, BREACH OF WARRANTY, OR
OTHER LEGAL EQUITABLE THEORY ANY DIRECT OR INDIRECT DAMAGES OR EXPENSES
INCLUDING BUT NOT LIMITED TO ANY INCIDENTAL, SPECIAL, INDIRECT, PUNITIVE OR
CONSEQUENTIAL DAMAGES, LOST PROFITS OR LOST DATA, COST OF PROCUREMENT OF
SUBSTITUTE GOODS, TECHNOLOGY, SERVICES, OR ANY CLAIMS BY THIRD PARTIES
(INCLUDING BUT NOT LIMITED TO ANY DEFENSE THEREOF), OR OTHER SIMILAR COSTS.
*******************************************************************************/
// DOM-IGNORE-END


#ifndef _GFX_HGC_DEFINITIONS_H
#define _GFX_HGC_DEFINITIONS_H

#include "system_config.h"
#include "system_definitions.h"

typedef enum
{
    HGC_STATE_INIT = 0,
    HGC_STATE_RUNNING
} HGC_STATES;

typedef enum
{
    HGC_SCREEN_STATE_INIT = 0,
    HGC_SCREEN_STATE_SETUP_SCREEN_screen1,
    HGC_SCREEN_STATE_PRE_DRAW_GOL_SCREEN_screen1,
    HGC_SCREEN_STATE_DRAW_GOL_SCREEN_screen1,
    HGC_SCREEN_STATE_POST_DRAW_GOL_SCREEN_screen1,
    HGC_SCREEN_STATE_PRE_DRAW_PRIMITIVE_SCREEN_screen1,
    HGC_SCREEN_STATE_DRAW_PRIMITIVE_SCREEN_screen1,
    HGC_SCREEN_STATE_POST_DRAW_PRIMITIVE_SCREEN_screen1,
    HGC_SCREEN_STATE_DISPLAY_SCREEN_screen1,
        
    HGC_SCREEN_STATE_SETUP_SCREEN_screen2,
    HGC_SCREEN_STATE_PRE_DRAW_GOL_SCREEN_screen2,
    HGC_SCREEN_STATE_DRAW_GOL_SCREEN_screen2,
    HGC_SCREEN_STATE_POST_DRAW_GOL_SCREEN_screen2,
    HGC_SCREEN_STATE_PRE_DRAW_PRIMITIVE_SCREEN_screen2,
    HGC_SCREEN_STATE_DRAW_PRIMITIVE_SCREEN_screen2,
    HGC_SCREEN_STATE_POST_DRAW_PRIMITIVE_SCREEN_screen2,
    HGC_SCREEN_STATE_DISPLAY_SCREEN_screen2,
        
    HGC_SCREEN_STATE_SETUP_SCREEN_screen3,
    HGC_SCREEN_STATE_PRE_DRAW_GOL_SCREEN_screen3,
    HGC_SCREEN_STATE_DRAW_GOL_SCREEN_screen3,
    HGC_SCREEN_STATE_POST_DRAW_GOL_SCREEN_screen3,
    HGC_SCREEN_STATE_PRE_DRAW_PRIMITIVE_SCREEN_screen3,
    HGC_SCREEN_STATE_DRAW_PRIMITIVE_SCREEN_screen3,
    HGC_SCREEN_STATE_POST_DRAW_PRIMITIVE_SCREEN_screen3,
    HGC_SCREEN_STATE_DISPLAY_SCREEN_screen3,
        
} HGC_SCREEN_STATES;

/*** GFX GOL Scheme Definitions ***/

#define GFX_SCHEME_NAME_0                       "default"
#define GFX_SCHEME_ALPHA_0                      100

#define GFX_SCHEME_BACKGROUND_OFFSET_TOP_0      0
#define GFX_SCHEME_BACKGROUND_OFFSET_LEFT_0     0

#define GFX_SCHEME_PRIMARY_COLOR_RED_0          0x00
#define GFX_SCHEME_PRIMARY_COLOR_GREEN_0        0x00
#define GFX_SCHEME_PRIMARY_COLOR_BLUE_0         0x00

#define GFX_SCHEME_SECONDARY_COLOR_RED_0        0x40
#define GFX_SCHEME_SECONDARY_COLOR_GREEN_0      0x40
#define GFX_SCHEME_SECONDARY_COLOR_BLUE_0       0x40

#define GFX_SCHEME_DISABLED_COLOR_RED_0         0x00
#define GFX_SCHEME_DISABLED_COLOR_GREEN_0       0x00
#define GFX_SCHEME_DISABLED_COLOR_BLUE_0        0x00

#define GFX_SCHEME_BACKGROUND_COLOR_RED_0       0x00
#define GFX_SCHEME_BACKGROUND_COLOR_GREEN_0     0x00
#define GFX_SCHEME_BACKGROUND_COLOR_BLUE_0      0x00

#define GFX_SCHEME_EMBOSS_SIZE_0                3

#define GFX_SCHEME_EMBOSS_LIGHT_COLOR_RED_0     0x00
#define GFX_SCHEME_EMBOSS_LIGHT_COLOR_GREEN_0   0x00
#define GFX_SCHEME_EMBOSS_LIGHT_COLOR_BLUE_0    0x00

#define GFX_SCHEME_EMBOSS_DARK_COLOR_RED_0      0x00
#define GFX_SCHEME_EMBOSS_DARK_COLOR_GREEN_0    0x00
#define GFX_SCHEME_EMBOSS_DARK_COLOR_BLUE_0     0x00

#define GFX_SCHEME_TEXT_PRIMARY_COLOR_RED_0     0xF8
#define GFX_SCHEME_TEXT_PRIMARY_COLOR_GREEN_0   0xFC
#define GFX_SCHEME_TEXT_PRIMARY_COLOR_BLUE_0    0xF8

#define GFX_SCHEME_TEXT_SECONDARY_COLOR_RED_0   0x00
#define GFX_SCHEME_TEXT_SECONDARY_COLOR_GREEN_0 0x00
#define GFX_SCHEME_TEXT_SECONDARY_COLOR_BLUE_0  0x00

#define GFX_SCHEME_TEXT_DISABLED_COLOR_RED_0    0x40
#define GFX_SCHEME_TEXT_DISABLED_COLOR_GREEN_0  0x40
#define GFX_SCHEME_TEXT_DISABLED_COLOR_BLUE_0   0x40

#define GFX_SCHEME_GRADIENT_START_COLOR_RED_0    0x00
#define GFX_SCHEME_GRADIENT_START_COLOR_GREEN_0  0x00
#define GFX_SCHEME_GRADIENT_START_COLOR_BLUE_0   0x00

#define GFX_SCHEME_GRADIENT_END_COLOR_RED_0    0x00
#define GFX_SCHEME_GRADIENT_END_COLOR_GREEN_0  0x00
#define GFX_SCHEME_GRADIENT_END_COLOR_BLUE_0   0x00

#define GFX_SCHEME_FILL_STYLE_0                GFX_FILL_STYLE_COLOR
#define GFX_SCHEME_BACKGROUND_TYPE_0           GFX_BACKGROUND_NONE

                
/*** GFX GOL Button Definitions ***/
#define GFX_STATICTEXT_LEFT_0            13
#define GFX_STATICTEXT_TOP_0             141
#define GFX_STATICTEXT_RIGHT_0           131
#define GFX_STATICTEXT_BOTTOM_0          191
#define GFX_STATICTEXT_STATE_0          GFX_GOL_STATICTEXT_DRAW_STATE
#define GFX_STATICTEXT_TEXT_0            "0x31, 0x36, 0x62, 0x69, 0x74, 0x20, 0x42, 0x50, 0x50, 0x0"
#define GFX_STATICTEXT_ALIGNMENT_0       GFX_ALIGN_LEFT | GFX_ALIGN_TOP
#define GFX_STATICTEXT_SCHEME_0          gfxScheme0
                
/*** static text IDs ***/
#define StaticText1                  700 
        
/*** GFX GOL windows Definitions ***/
#define GFX_PICTURE_LEFT_0            7
#define GFX_PICTURE_TOP_0             8
#define GFX_PICTURE_RIGHT_0           107
#define GFX_PICTURE_BOTTOM_0          137
#define GFX_PICTURE_STATE_0          GFX_GOL_PICTURECONTROL_DRAW_STATE
#define GFX_PICTURE_SCALE_0       1
#define GFX_PICTURE_SCHEME_0          gfxScheme0
                
/*** Pictures IDs ***/
#define Picture1                  800 
        
/*** Line IDs ***/
#define Line11                 950 
        
#define Line10                 951 
        
#define Line9                 952 
        
#define Line8                 953 
        
#define Line7                 954 
        
#define Line6                 955 
        
#define Line5                 956 
        
#define Line4                 957 
        
#define Line3                 958 
        
#define Line2                 959 
        
#define Line1                 960 
        
/*** Rectangle IDs ***/
#define Rectangle5                 1000 
        
#define Rectangle4                 1001 
        
#define Rectangle1                 1002 
        
#define Rectangle3                 1003 
        
#define Rectangle2                 1004 
        
/*** Circle IDs ***/
#define Circle10                 1050 

#define Circle9                 1051 
        
#define Circle8                 1052 
        
#define Circle7                 1053 
        
#define Circle6                 1054 
        
#define Circle5                 1055 
        
#define Circle4                 1056 
        
#define Circle3                 1057 
        
#define Circle2                 1058 
        
#define Circle1                 1059 
        
/*** Screen IDs ***/
#define screen1                 0 
        
#define screen2                 1 

#define screen3                 2 



// *****************************************************************************
/* MPLAB Harmony Graphics Composer Objects

  Summary:
    Structure holding the graphics object handles

  Description:
    This structure contains the object handles for all graphics objects 
    generated by the Harmony Graphics Composer

  Remarks:
*/

typedef struct HGC_OBJECTS
{
    HGC_SCREEN_STATES screenState;      // current state of screen state machine
    HGC_SCREEN_STATES prevRefreshState; // previous state of screen state machine

//    DRV_TOUCH_SAMPLE_POINTS samplePoints;

    /*** GOL Objects References ***/
    GFX_GOL_STATICTEXT* pStaticText1Obj;
    GFX_GOL_PICTURECONTROL* pPicture1Obj;
} HGC_OBJECTS;

extern HGC_OBJECTS hgcObj;

/******************************************************************************
  Function:
    void GFX_HGC_Setup ( void )

  Summary:
    This function sets up the GOL message callback and draw callbacks.  
 */
void GFX_HGC_Setup ( void );


/******************************************************************************
  Function:
    HGC_SCREEN_STATES GFX_HGC_GetScreenState ( void )

  Remarks:
    This function returns the screen state
 */
HGC_SCREEN_STATES GFX_HGC_GetScreenState ( void );


/******************************************************************************
  Function:
    void GFX_HGC_SetScreenState ( HGC_SCREEN_STATES newState )

  Remarks:
    This function sets the screen state machine to a new state
 */
void GFX_HGC_SetScreenState ( HGC_SCREEN_STATES newState );


/******************************************************************************
  Function:
    void GFX_HGC_Tasks (SYS_MODULE_OBJ gfxObject);

  Summary:
    This function is called in SYS_Tasks.  The intent wait until the GFX library
    is initialized before supplying items to draw
*/
void GFX_HGC_Tasks  (SYS_MODULE_OBJ gfxObject);


/******************************************************************************
  Function:
    void GFX_HGC_SchemeCreate ( void )

  Summary:
    Allocates memory for a new scheme
 */
GFX_GOL_OBJ_SCHEME *GFX_HGC_SchemeCreate(void);


/******************************************************************************
  Function:
    void GFX_HGC_InitializeSchemes ( void )

  Summary:
    Initializes all HGC-specified schemes
 */
void GFX_HGC_InitializeSchemes( void );


/******************************************************************************
  Function: 
    bool GFX_HGC_MESSAGECallback(uint16_t objMsg, GFX_GOL_OBJ_HEADER* pObj, GFX_GOL_MESSAGE* pMsg)

  Input: 
    objMsg - translated message for the object,
    pObj - pointer to the object,
    pMsg - pointer to the non-translated, raw GOL message

  Output: 
    If the function returns non-zero the message will be processed by default

  Remarks: 
    GFX_GOL_MESSAGECallback() function calls it each time the valid message for the GOL object is received.
 */
bool GFX_HGC_MessageCallback(GFX_GOL_TRANSLATED_ACTION objMsg, GFX_GOL_OBJ_HEADER *pObj, GFX_GOL_MESSAGE *pMsg);


/******************************************************************************
  Function: 
    bool GFX_HGC_DrawCallback( void )

  Output: 
    If the function returns non-zero the draw control will be passed to GOL

  Remarks: 
    GFX_GOL_Draw() function calls it each time when GOL objects drawing is 
    completed. HGC-specified draw data is grouped by screens states. It takes 
    two states to complete the drawing of each screen.  GFX GOL objects are drawn
    first and then GFX Primitives are drawn next to ensure primitives are not
    covered by GOL objects.
 */
bool GFX_HGC_DrawCallback( void );
/******************************************************************************
  Function: 
    bool GFX_HGC_DrawScreen_GOL( uint8_t  screenId )

  Output: 
    Returns true if a screenId matches an existing screen identifier

  Remarks: 
    HGC-specified GFX GOL objects are drawn here, grouped by screen.
    The draw order is reverse Z-ordered.
 */
bool GFX_HGC_DrawScreen_GOL(uint8_t screenId);


/******************************************************************************
  Function: 
    bool GFX_HGC_DrawScreen_Primitives( uint8_t  screenId )

  Output:
    Returns true if a screenId matches an existing screen identifier

  Remarks: 
    HGC-specified GFX Primitives are drawn here, grouped by screen.
    GFX Primitives are drawn after GFX GOL Objects to make sure GFX GOL Objects
    do not cover GFX Primitives
 */
bool GFX_HGC_DrawScreen_Primitives(uint8_t screenId);


/******************************************************************************
  Function: 
    void GFX_HGC_SetupScreen( uint8_t  screenId )

  Remarks: 
    Clears current screen and starts a fresh screen with its background color
 */
void GFX_HGC_SetupScreen(uint8_t screenId);


/******************************************************************************
  Function: 
    bool GFX_HGC_ChangeScreen( uint8_t  screenId )

  Output: 
    Returns true if a screenId matches an existing screen identifier

  Remarks: 
    Can be called to initiate GFX Library to draw a new screen
 */
bool GFX_HGC_ChangeScreen(uint8_t screenId);


/******************************************************************************
  Function: 
    bool GFX_HGC_DrawItem(int itemId)

  Output:
    Returns true if a itemId matches an existing item identifier

  Remarks: 
    Every item specified in every screen in HGC is listed in this function
 */
bool GFX_HGC_DrawItem(int itemId);


/******************************************************************************
  Function: 
    bool GFX_HGC_MsgPictures(uint16_t objMsg, GFX_GOL_OBJ_HEADER *pObj)

  Output:
    Returns true if a Object ID matches an existing item identifier

  Remarks: 
    Handles GFX GOL Picture Control events
 */
bool GFX_HGC_MsgPictures(uint16_t objMsg, GFX_GOL_OBJ_HEADER *pObj);

/******************************************************************************
  Function: 
    bool GFX_HGC_MsgStaticTexts(uint16_t objMsg, GFX_GOL_OBJ_HEADER *pObj)

  Output:
    Returns true if a Object ID matches an existing item identifier

  Remarks: 
    Handles GFX GOL Static Text events
 */
bool GFX_HGC_MsgStaticTexts(uint16_t objMsg, GFX_GOL_OBJ_HEADER *pObj);

#endif // _GFX_HGC_DEFINITIONS_H
/*******************************************************************************
 End of File
*/



//以下、gfx_hgc_definitions.c
//-------------------------------------------------------------------------
/*******************************************************************************
  MPLAB Harmony Graphics Composer Generated Implementation File

  File Name:
    gfx_hgc_definitions.c

  Summary:
    Build-time generated implementation from the MPLAB Harmony
    Graphics Composer.

  Description:
    Build-time generated implementation from the MPLAB Harmony
    Graphics Composer.

    Created with MPLAB Harmony Version 1.05
*******************************************************************************/
// DOM-IGNORE-BEGIN
/*******************************************************************************
Copyright (c) 2013-2014 released Microchip Technology Inc.  All rights reserved.

Microchip licenses to you the right to use, modify, copy and distribute
Software only when embedded on a Microchip microcontroller or digital signal
controller that is integrated into your product or third party product
(pursuant to the sublicense terms in the accompanying license agreement).

You should refer to the license agreement accompanying this Software for
additional information regarding your rights and obligations.

SOFTWARE AND DOCUMENTATION ARE PROVIDED AS IS WITHOUT WARRANTY OF ANY KIND,
EITHER EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION, ANY WARRANTY OF
MERCHANTABILITY, TITLE, NON-INFRINGEMENT AND FITNESS FOR A PARTICULAR PURPOSE.
IN NO EVENT SHALL MICROCHIP OR ITS LICENSORS BE LIABLE OR OBLIGATED UNDER
CONTRACT, NEGLIGENCE, STRICT LIABILITY, CONTRIBUTION, BREACH OF WARRANTY, OR
OTHER LEGAL EQUITABLE THEORY ANY DIRECT OR INDIRECT DAMAGES OR EXPENSES
INCLUDING BUT NOT LIMITED TO ANY INCIDENTAL, SPECIAL, INDIRECT, PUNITIVE OR
CONSEQUENTIAL DAMAGES, LOST PROFITS OR LOST DATA, COST OF PROCUREMENT OF
SUBSTITUTE GOODS, TECHNOLOGY, SERVICES, OR ANY CLAIMS BY THIRD PARTIES
(INCLUDING BUT NOT LIMITED TO ANY DEFENSE THEREOF), OR OTHER SIMILAR COSTS.
*******************************************************************************/
// DOM-IGNORE-END

#include "gfx_hgc_definitions.h"

/*** Default GFX GOL Scheme ***/
#define GFX_SCHEMEDEFAULT GOLSchemeDefault
extern GFX_GOL_OBJ_SCHEME GFX_SCHEMEDEFAULT;

/*** HGC-specified GFX GOL Scheme ***/
static GFX_GOL_OBJ_SCHEME *gfxScheme0;

/*** Generated Asset References ***/
extern const GFX_RESOURCE_HDR flower16bit;
extern const GFX_RESOURCE_HDR fireflysung;

/*** Generated ASCII Text Labels ***/
static const GFX_XCHAR staticTextStr_0[] = { 0x31, 0x36, 0x62, 0x69, 0x74, 0x20, 0x42, 0x50, 0x50, 0x0 }; // 16bit BPP
/*** HGC Object Global ***/
HGC_OBJECTS hgcObj;
static HGC_STATES hgcState;

/******************************************************************************
  Function:
    HGC_SCREEN_STATES GFX_HGC_GetScreenState ( void )

  Remarks:
    This function returns the screen state
 */
HGC_SCREEN_STATES GFX_HGC_GetScreenState ( void )
{
    return hgcObj.screenState;
}


/******************************************************************************
  Function:
    void GFX_HGC_SetScreenState ( HGC_SCREEN_STATES newState )

  Remarks:
    This function sets the screen state machine to a new state
 */
void GFX_HGC_SetScreenState ( HGC_SCREEN_STATES newState )
{
    hgcObj.prevRefreshState = hgcObj.screenState;
    hgcObj.screenState = newState;
}


/******************************************************************************
  Function:
    void GFX_HGC_Setup ( void )

  Summary:
    This function sets up the GOL message callback and draw callbacks.  
 */
void GFX_HGC_Setup ( void )
{
    GFX_GOL_MessageCallbackSet(GFX_INDEX_0, &GFX_HGC_MessageCallback);
    GFX_GOL_DrawCallbackSet(GFX_INDEX_0, &GFX_HGC_DrawCallback);

    GFX_HGC_InitializeSchemes();

}

/******************************************************************************
  Function:
    void GFX_HGC_Tasks (SYS_MODULE_OBJ gfxObject);

  Summary:
    This function is called in SYS_Tasks.  The intent wait until the GFX library
    is initialized before supplying items to draw
*/
void GFX_HGC_Tasks  (SYS_MODULE_OBJ gfxObject)
{
    switch ( hgcState )
    {
        case HGC_STATE_INIT:
            if (GFX_Status(gfxObject)==SYS_STATUS_READY)
            {
                GFX_HGC_Setup();
                hgcState = HGC_STATE_RUNNING;
            }
            break;

        case HGC_STATE_RUNNING:
            break;

        default:
            break;
    }
}

/******************************************************************************
  Function:
    void GFX_HGC_SchemeCreate ( void )

  Summary:
    Allocates memory for a new scheme
 */
GFX_GOL_OBJ_SCHEME *GFX_HGC_SchemeCreate(void)
{
    GFX_GOL_OBJ_SCHEME  *pTemp;

    pTemp = (GFX_GOL_OBJ_SCHEME *)GFX_malloc(sizeof(GFX_GOL_OBJ_SCHEME));

    if(pTemp != NULL)
    {
        memcpy(pTemp, &GFX_SCHEMEDEFAULT, sizeof(GFX_GOL_OBJ_SCHEME));
    }

    return (pTemp);
}

/******************************************************************************
  Function:
    void GFX_HGC_InitializeSchemes ( void )

  Summary:
    Initializes all HGC-specified schemes
 */
void GFX_HGC_InitializeSchemes( void )
{
    gfxScheme0 = GFX_HGC_SchemeCreate();

#ifndef GFX_CONFIG_ALPHABLEND_DISABLE
    gfxScheme0->AlphaValue =        GFX_SCHEME_ALPHA_0;
#endif
    gfxScheme0->Color0 =            GFX_RGBConvert(GFX_SCHEME_PRIMARY_COLOR_RED_0, GFX_SCHEME_PRIMARY_COLOR_GREEN_0, GFX_SCHEME_PRIMARY_COLOR_BLUE_0);
    gfxScheme0->Color1 =            GFX_RGBConvert(GFX_SCHEME_SECONDARY_COLOR_RED_0, GFX_SCHEME_SECONDARY_COLOR_GREEN_0, GFX_SCHEME_SECONDARY_COLOR_BLUE_0);
    gfxScheme0->ColorDisabled =     GFX_RGBConvert(GFX_SCHEME_DISABLED_COLOR_RED_0, GFX_SCHEME_DISABLED_COLOR_GREEN_0, GFX_SCHEME_DISABLED_COLOR_BLUE_0);
    gfxScheme0->CommonBkColor =     GFX_RGBConvert(GFX_SCHEME_BACKGROUND_COLOR_RED_0, GFX_SCHEME_BACKGROUND_COLOR_GREEN_0, GFX_SCHEME_BACKGROUND_COLOR_BLUE_0);
        gfxScheme0->EmbossSize =        GFX_SCHEME_EMBOSS_SIZE_0;
    gfxScheme0->EmbossDkColor =     GFX_RGBConvert(GFX_SCHEME_EMBOSS_DARK_COLOR_RED_0, GFX_SCHEME_EMBOSS_DARK_COLOR_GREEN_0, GFX_SCHEME_EMBOSS_DARK_COLOR_BLUE_0);
    gfxScheme0->EmbossLtColor =     GFX_RGBConvert(GFX_SCHEME_EMBOSS_LIGHT_COLOR_RED_0, GFX_SCHEME_EMBOSS_LIGHT_COLOR_GREEN_0, GFX_SCHEME_EMBOSS_LIGHT_COLOR_BLUE_0);
        gfxScheme0->TextColor0 =        GFX_RGBConvert(GFX_SCHEME_TEXT_PRIMARY_COLOR_RED_0, GFX_SCHEME_TEXT_PRIMARY_COLOR_GREEN_0, GFX_SCHEME_TEXT_PRIMARY_COLOR_BLUE_0);
    gfxScheme0->TextColor1 =        GFX_RGBConvert(GFX_SCHEME_TEXT_SECONDARY_COLOR_RED_0, GFX_SCHEME_TEXT_SECONDARY_COLOR_GREEN_0, GFX_SCHEME_TEXT_SECONDARY_COLOR_BLUE_0);
    gfxScheme0->TextColorDisabled = GFX_RGBConvert(GFX_SCHEME_TEXT_DISABLED_COLOR_RED_0, GFX_SCHEME_TEXT_DISABLED_COLOR_GREEN_0, GFX_SCHEME_TEXT_DISABLED_COLOR_BLUE_0);
#ifndef GFX_CONFIG_GRADIENT_DISABLE
        gfxScheme0->gradientStartColor = GFX_RGBConvert(GFX_SCHEME_GRADIENT_START_COLOR_RED_0, GFX_SCHEME_GRADIENT_START_COLOR_GREEN_0, GFX_SCHEME_GRADIENT_START_COLOR_BLUE_0);
        gfxScheme0->gradientEndColor = GFX_RGBConvert(GFX_SCHEME_GRADIENT_END_COLOR_RED_0, GFX_SCHEME_GRADIENT_END_COLOR_GREEN_0, GFX_SCHEME_GRADIENT_END_COLOR_BLUE_0);
#endif
    gfxScheme0->CommonBkLeft =      GFX_SCHEME_BACKGROUND_OFFSET_TOP_0;
    gfxScheme0->CommonBkTop =       GFX_SCHEME_BACKGROUND_OFFSET_LEFT_0;
    gfxScheme0->pFont =             (GFX_RESOURCE_HDR*)&fireflysung;
    gfxScheme0->pCommonBkImage =    (GFX_RESOURCE_HDR*)NULL;
        
        gfxScheme0->fillStyle =         GFX_SCHEME_FILL_STYLE_0;
        gfxScheme0->CommonBkType =      GFX_SCHEME_BACKGROUND_TYPE_0;

}

/******************************************************************************
  Function: 
    bool GFX_HGC_MESSAGECallback(uint16_t objMsg, GFX_GOL_OBJ_HEADER* pObj, GFX_GOL_MESSAGE* pMsg)

  Input: 
    objMsg - translated message for the object,
    pObj - pointer to the object,
    pMsg - pointer to the non-translated, raw GOL message

  Output: 
    If the function returns non-zero the message will be processed by default

  Remarks: 
    GFX_GOL_MESSAGECallback() function calls it each time the valid message for the GOL object is received.
 */
bool GFX_HGC_MessageCallback(GFX_GOL_TRANSLATED_ACTION objMsg, GFX_GOL_OBJ_HEADER *pObj, GFX_GOL_MESSAGE *pMsg)
{
    // process messages for demo screens
    switch (hgcObj.screenState)
    {
        case HGC_SCREEN_STATE_DISPLAY_SCREEN_screen1:
            if (GFX_HGC_MsgPictures(objMsg, pObj) == true)
                return true;
            if (GFX_HGC_MsgStaticTexts(objMsg, pObj) == true)
                return true;
            break;
        case HGC_SCREEN_STATE_DISPLAY_SCREEN_screen2:
            if (GFX_HGC_MsgPictures(objMsg, pObj) == true)
                return true;
            if (GFX_HGC_MsgStaticTexts(objMsg, pObj) == true)
                return true;
            break;
        case HGC_SCREEN_STATE_DISPLAY_SCREEN_screen3:
            if (GFX_HGC_MsgPictures(objMsg, pObj) == true)
                return true;
            if (GFX_HGC_MsgStaticTexts(objMsg, pObj) == true)
                return true;
            break;
      default:
            // process message by default
            return true;
    }
    return true;
}

/******************************************************************************
  Function: 
    bool GFX_HGC_DrawCallback( void )

  Output: 
    If the function returns non-zero the draw control will be passed to GOL

  Remarks: 
    GFX_GOL_Draw() function calls it each time when GOL objects drawing is 
    completed. HGC-specified draw data is grouped by screens states. It takes 
    two states to complete the drawing of each screen.  GFX GOL objects are drawn
    first and then GFX Primitives are drawn next to ensure primitives are not
    covered by GOL objects.
 */
bool GFX_HGC_DrawCallback( void )
{
    switch (hgcObj.screenState)
    {
        case HGC_SCREEN_STATE_INIT:
            //Draw the primary screen as selected in the Composer
            GFX_HGC_SetScreenState(HGC_SCREEN_STATE_SETUP_SCREEN_screen1);
            return true;
        case HGC_SCREEN_STATE_SETUP_SCREEN_screen1:
            GFX_HGC_SetScreenState(HGC_SCREEN_STATE_PRE_DRAW_GOL_SCREEN_screen1);
            break;
        case HGC_SCREEN_STATE_PRE_DRAW_GOL_SCREEN_screen1:
            GFX_HGC_SetScreenState(HGC_SCREEN_STATE_DRAW_GOL_SCREEN_screen1);
            break;
        case HGC_SCREEN_STATE_DRAW_GOL_SCREEN_screen1:
            GFX_HGC_SetupScreen(screen1);
            GFX_HGC_DrawScreen_GOL(screen1);
            GFX_HGC_SetScreenState(HGC_SCREEN_STATE_POST_DRAW_GOL_SCREEN_screen1);
            break;
        case HGC_SCREEN_STATE_POST_DRAW_GOL_SCREEN_screen1:
            GFX_HGC_SetScreenState(HGC_SCREEN_STATE_PRE_DRAW_PRIMITIVE_SCREEN_screen1);
            break;
        case HGC_SCREEN_STATE_PRE_DRAW_PRIMITIVE_SCREEN_screen1:
            GFX_HGC_SetScreenState(HGC_SCREEN_STATE_DRAW_PRIMITIVE_SCREEN_screen1);
            break;
        case HGC_SCREEN_STATE_DRAW_PRIMITIVE_SCREEN_screen1:
            GFX_HGC_DrawScreen_Primitives(screen1);
            GFX_HGC_SetScreenState(HGC_SCREEN_STATE_POST_DRAW_PRIMITIVE_SCREEN_screen1);
            break;
        case HGC_SCREEN_STATE_POST_DRAW_PRIMITIVE_SCREEN_screen1:
            GFX_HGC_SetScreenState(HGC_SCREEN_STATE_DISPLAY_SCREEN_screen1);
            break;
        case HGC_SCREEN_STATE_DISPLAY_SCREEN_screen1:
            break;
        case HGC_SCREEN_STATE_SETUP_SCREEN_screen2:
            GFX_HGC_SetScreenState(HGC_SCREEN_STATE_PRE_DRAW_GOL_SCREEN_screen2);
            break;
        case HGC_SCREEN_STATE_PRE_DRAW_GOL_SCREEN_screen2:
            GFX_HGC_SetScreenState(HGC_SCREEN_STATE_DRAW_GOL_SCREEN_screen2);
            break;
        case HGC_SCREEN_STATE_DRAW_GOL_SCREEN_screen2:
            GFX_HGC_SetupScreen(screen2);
            GFX_HGC_DrawScreen_GOL(screen2);
            GFX_HGC_SetScreenState(HGC_SCREEN_STATE_POST_DRAW_GOL_SCREEN_screen2);
            break;
        case HGC_SCREEN_STATE_POST_DRAW_GOL_SCREEN_screen2:
            GFX_HGC_SetScreenState(HGC_SCREEN_STATE_PRE_DRAW_PRIMITIVE_SCREEN_screen2);
            break;
        case HGC_SCREEN_STATE_PRE_DRAW_PRIMITIVE_SCREEN_screen2:
            GFX_HGC_SetScreenState(HGC_SCREEN_STATE_DRAW_PRIMITIVE_SCREEN_screen2);
            break;
        case HGC_SCREEN_STATE_DRAW_PRIMITIVE_SCREEN_screen2:
            GFX_HGC_DrawScreen_Primitives(screen2);
            GFX_HGC_SetScreenState(HGC_SCREEN_STATE_POST_DRAW_PRIMITIVE_SCREEN_screen2);
            break;
        case HGC_SCREEN_STATE_POST_DRAW_PRIMITIVE_SCREEN_screen2:
            GFX_HGC_SetScreenState(HGC_SCREEN_STATE_DISPLAY_SCREEN_screen2);
            break;
        case HGC_SCREEN_STATE_DISPLAY_SCREEN_screen2:
            break;
        case HGC_SCREEN_STATE_SETUP_SCREEN_screen3:
            GFX_HGC_SetScreenState(HGC_SCREEN_STATE_PRE_DRAW_GOL_SCREEN_screen3);
            break;
        case HGC_SCREEN_STATE_PRE_DRAW_GOL_SCREEN_screen3:
            GFX_HGC_SetScreenState(HGC_SCREEN_STATE_DRAW_GOL_SCREEN_screen3);
            break;
        case HGC_SCREEN_STATE_DRAW_GOL_SCREEN_screen3:
            GFX_HGC_SetupScreen(screen3);
            GFX_HGC_DrawScreen_GOL(screen3);
            GFX_HGC_SetScreenState(HGC_SCREEN_STATE_POST_DRAW_GOL_SCREEN_screen3);
            break;
        case HGC_SCREEN_STATE_POST_DRAW_GOL_SCREEN_screen3:
            GFX_HGC_SetScreenState(HGC_SCREEN_STATE_PRE_DRAW_PRIMITIVE_SCREEN_screen3);
            break;
        case HGC_SCREEN_STATE_PRE_DRAW_PRIMITIVE_SCREEN_screen3:
            GFX_HGC_SetScreenState(HGC_SCREEN_STATE_DRAW_PRIMITIVE_SCREEN_screen3);
            break;
        case HGC_SCREEN_STATE_DRAW_PRIMITIVE_SCREEN_screen3:
            GFX_HGC_DrawScreen_Primitives(screen3);
            GFX_HGC_SetScreenState(HGC_SCREEN_STATE_POST_DRAW_PRIMITIVE_SCREEN_screen3);
            break;
        case HGC_SCREEN_STATE_POST_DRAW_PRIMITIVE_SCREEN_screen3:
            GFX_HGC_SetScreenState(HGC_SCREEN_STATE_DISPLAY_SCREEN_screen3);
            break;
        case HGC_SCREEN_STATE_DISPLAY_SCREEN_screen3:
            break;
        default:
            return true; // release drawing control to GOL by default
    }

    return true; // release drawing control to GOL
}

/******************************************************************************
  Function: 
    void GFX_HGC_SetupScreen( uint8_t  screenId )

  Remarks: 
    Clears current screen and starts a fresh screen with its background color
 */
void GFX_HGC_SetupScreen(uint8_t screenId)
{
    switch (screenId)
    {
        case screen1:
            GFX_ColorSet(GFX_INDEX_0, GFX_RGBConvert(0x00, 0x00, 0x00));
            GFX_ScreenClear(GFX_INDEX_0);

            GFX_GOL_ObjectListFree(GFX_INDEX_0); // free memory for the objects in the previous linked list and start new list
            break;
        case screen2:
            GFX_ColorSet(GFX_INDEX_0, GFX_RGBConvert(0x00, 0x00, 0x00));
            GFX_ScreenClear(GFX_INDEX_0);

            GFX_GOL_ObjectListFree(GFX_INDEX_0); // free memory for the objects in the previous linked list and start new list
            break;
        case screen3:
            GFX_ColorSet(GFX_INDEX_0, GFX_RGBConvert(0x00, 0x00, 0x00));
            GFX_ScreenClear(GFX_INDEX_0);

            GFX_GOL_ObjectListFree(GFX_INDEX_0); // free memory for the objects in the previous linked list and start new list
            break;
        default:
            break;
    }
}


/******************************************************************************
  Function: 
    bool GFX_HGC_ChangeScreen( uint8_t  screenId )

  Output: 
    Returns true if a screenId matches an existing screen identifier

  Remarks: 
    Can be called to initiate GFX Library to draw a new screen
 */
bool GFX_HGC_ChangeScreen(uint8_t screenId)
{
    switch (screenId)
    {
        case screen1:
            GFX_HGC_SetScreenState(HGC_SCREEN_STATE_SETUP_SCREEN_screen1);
            break;
        case screen2:
            GFX_HGC_SetScreenState(HGC_SCREEN_STATE_SETUP_SCREEN_screen2);
            break;
        case screen3:
            GFX_HGC_SetScreenState(HGC_SCREEN_STATE_SETUP_SCREEN_screen3);
            break;
        default:
            return false;
    }

    return true; // release drawing control to GOL
}

/******************************************************************************
  Function: 
    bool GFX_HGC_DrawScreen_GOL( uint8_t  screenId )

  Output: 
    Returns true if a screenId matches an existing screen identifier

  Remarks: 
    HGC-specified GFX GOL objects are drawn here, grouped by screen.
    The draw order is reverse Z-ordered.
 */
bool GFX_HGC_DrawScreen_GOL(uint8_t screenId)
{
    switch (screenId)
    {
        case screen1:
            break;
        case screen2:
            GFX_HGC_DrawItem(Picture1);
            GFX_HGC_DrawItem(StaticText1);
            break;
        case screen3:
            break;
        default:
            return false;
    }

    return true; // release drawing control to GOL
}


/******************************************************************************
  Function: 
    bool GFX_HGC_DrawScreen_Primitives( uint8_t  screenId )

  Output:
    Returns true if a screenId matches an existing screen identifier

  Remarks: 
    HGC-specified GFX Primitives are drawn here, grouped by screen.
    GFX Primitives are drawn after GFX GOL Objects to make sure GFX GOL Objects
    do not cover GFX Primitives
 */
bool GFX_HGC_DrawScreen_Primitives(uint8_t screenId)
{
    switch (screenId)
    {
        case screen1:
            GFX_HGC_DrawItem(Circle1);
            GFX_HGC_DrawItem(Circle2);
            GFX_HGC_DrawItem(Circle3);
            GFX_HGC_DrawItem(Circle4);
            GFX_HGC_DrawItem(Circle5);
            GFX_HGC_DrawItem(Circle6);
            GFX_HGC_DrawItem(Circle7);
            GFX_HGC_DrawItem(Circle8);
            GFX_HGC_DrawItem(Circle9);
            GFX_HGC_DrawItem(Circle10);
            GFX_HGC_DrawItem(Line1);
            GFX_HGC_DrawItem(Line2);
            GFX_HGC_DrawItem(Line3);
            GFX_HGC_DrawItem(Line4);
            GFX_HGC_DrawItem(Line5);
            GFX_HGC_DrawItem(Line6);
            GFX_HGC_DrawItem(Line7);
            GFX_HGC_DrawItem(Line8);
            GFX_HGC_DrawItem(Line9);
            GFX_HGC_DrawItem(Line10);
            GFX_HGC_DrawItem(Line11);
            break;
        case screen2:
            break;
        case screen3:
            GFX_HGC_DrawItem(Rectangle2);
            GFX_HGC_DrawItem(Rectangle3);
            GFX_HGC_DrawItem(Rectangle1);
            GFX_HGC_DrawItem(Rectangle4);
            GFX_HGC_DrawItem(Rectangle5);
            break;
        default:
            return true;
    }

    return true; // release drawing control to GOL
}


/******************************************************************************
  Function: 
    bool GFX_HGC_DrawItem(int itemId)

  Output:
    Returns true if a itemId matches an existing item identifier

  Remarks: 
    Every item specified in every screen in HGC is listed in this function
 */
bool GFX_HGC_DrawItem(int itemId)
{
    switch(itemId)
    {
    case StaticText1:
        hgcObj.pStaticText1Obj = GFX_GOL_StaticTextCreate
                (
                 GFX_INDEX_0,
                 StaticText1,      // button ID
                 GFX_STATICTEXT_LEFT_0,    // left
                 GFX_STATICTEXT_TOP_0,     // top
                 GFX_STATICTEXT_RIGHT_0,   // right
                 GFX_STATICTEXT_BOTTOM_0,  // bottom
                 GFX_STATICTEXT_STATE_0,   // state
                 (GFX_XCHAR*)staticTextStr_0,    // text
                 GFX_STATICTEXT_ALIGNMENT_0,       //alignment
                 GFX_STATICTEXT_SCHEME_0
                 ); // use alternate scheme
        break;
    case Picture1:
        hgcObj.pPicture1Obj = GFX_GOL_PictureControlCreate
                (
                 GFX_INDEX_0,
                 Picture1,      // picture ID
                 GFX_PICTURE_LEFT_0,    // left
                 GFX_PICTURE_TOP_0,     // top
                 GFX_PICTURE_RIGHT_0,   // right                                 
                 GFX_PICTURE_BOTTOM_0,  // bottom
                                 GFX_PICTURE_STATE_0,   // state                 
                 GFX_PICTURE_SCALE_0,     // scale
                 (GFX_RESOURCE_HDR*)&flower16bit,    // bitmap
                 GFX_PICTURE_SCHEME_0
                 );
        break;
                case Line11:
                {
                        GFX_ColorSet(GFX_INDEX_0, GFX_RGBConvert(0xF8, 0xFC, 0xF8));
                        GFX_LineStyleSet(GFX_INDEX_0, GFX_LINE_STYLE_THIN_SOLID);
                        GFX_LineDraw(GFX_INDEX_0,
                                                 240/6*5,   //267,  // p1x
                                                 0,  // p1y
                                                 240/6, //53,  // p2x
                                                 319);  //239); // p2y
                        break;
                }               
                case Line10:
                {
                        GFX_ColorSet(GFX_INDEX_0, GFX_RGBConvert(0xF8, 0xFC, 0xF8));
                        GFX_LineStyleSet(GFX_INDEX_0, GFX_LINE_STYLE_THIN_SOLID);
                        GFX_LineDraw(GFX_INDEX_0,
                                                 240/6*4,   //214,  // p1x
                                                 0,  // p1y
                                                 240/6*2,   //106,  // p2x
                                                 319);  //239); // p2y
                        break;
                }               
                case Line9:
                {
                        GFX_ColorSet(GFX_INDEX_0, GFX_RGBConvert(0xF8, 0xFC, 0xF8));
                        GFX_LineStyleSet(GFX_INDEX_0, GFX_LINE_STYLE_THIN_SOLID);
                        GFX_LineDraw(GFX_INDEX_0,
                                                 240/6*2,   //106,  // p1x
                                                 0,  // p1y
                                                 240/6*4,   //214,  // p2x
                                                 319);  //239); // p2y
                        break;
                }               
                case Line8:
                {
                        GFX_ColorSet(GFX_INDEX_0, GFX_RGBConvert(0xF8, 0xFC, 0xF8));
                        GFX_LineStyleSet(GFX_INDEX_0, GFX_LINE_STYLE_THIN_SOLID);
                        GFX_LineDraw(GFX_INDEX_0,
                                                 240/6, //53,  // p1x
                                                 0,  // p1y
                                                 240/6*5,   //267,  // p2x
                                                 319);  //239); // p2y
                        break;
                }               
                case Line7:
                {
                        GFX_ColorSet(GFX_INDEX_0, GFX_RGBConvert(0xF8, 0xFC, 0xF8));
                        GFX_LineStyleSet(GFX_INDEX_0, GFX_LINE_STYLE_THIN_SOLID);
                        GFX_LineDraw(GFX_INDEX_0,
                                                120,    // 160,  // p1x
                                                 0,  // p1y
                                                120,    // 160,  // p2x
                                                319);    // 239); // p2y
                        break;
                }               
                case Line6:
                {
                        GFX_ColorSet(GFX_INDEX_0, GFX_RGBConvert(0xF8, 0xFC, 0xF8));
                        GFX_LineStyleSet(GFX_INDEX_0, GFX_LINE_STYLE_THIN_SOLID);
                        GFX_LineDraw(GFX_INDEX_0,
                                                 0,  // p1x
                                                 319,   //239,  // p1y
                                                 239,   //319,  // p2x
                                                 0); // p2y
                        break;
                }               
                case Line5:
                {
                        GFX_ColorSet(GFX_INDEX_0, GFX_RGBConvert(0xF8, 0xFC, 0xF8));
                        GFX_LineStyleSet(GFX_INDEX_0, GFX_LINE_STYLE_THIN_SOLID);
                        GFX_LineDraw(GFX_INDEX_0,
                                                 0,  // p1x
                                                 0,  // p1y
                                                 239,   //319,  // p2x
                                                 319);   //239); // p2y
                        break;
                }               
                case Line4: //LIGHT GREEN
                {
                        GFX_ColorSet(GFX_INDEX_0, GFX_RGBConvert(0x00, 0xFC, 0x00));
                        GFX_LineStyleSet(GFX_INDEX_0, GFX_LINE_STYLE_THIN_SOLID);
                        GFX_LineDraw(GFX_INDEX_0,
                                                 239,   //319,  // p1x
                                                 0,  // p1y
                                                 239,   //319,  // p2x
                                                 319);  //239); // p2y
                        break;
                }               
                case Line3: //YELLOW
                {
                        GFX_ColorSet(GFX_INDEX_0, GFX_RGBConvert(0xF8, 0xFC, 0x00));
                        GFX_LineStyleSet(GFX_INDEX_0, GFX_LINE_STYLE_THIN_SOLID);
                        GFX_LineDraw(GFX_INDEX_0,
                                                 0,  // p1x
                                                 0,  // p1y
                                                 0,  // p2x
                                                 319);  //239); // p2y
                        break;
                }               
                case Line2: //BLUE
                {
                        GFX_ColorSet(GFX_INDEX_0, GFX_RGBConvert(0x00, 0x00, 0xF8));
                        GFX_LineStyleSet(GFX_INDEX_0, GFX_LINE_STYLE_THIN_SOLID);
                        GFX_LineDraw(GFX_INDEX_0,
                                                 0,  // p1x
                                                 319,   //239,  // p1y
                                                 239,   //319,  // p2x
                                                 319);  //239); // p2y
                        break;
                }               
                case Line1: //RED
                {
                        GFX_ColorSet(GFX_INDEX_0, GFX_RGBConvert(0xF8, 0x00, 0x00));
                        GFX_LineStyleSet(GFX_INDEX_0, GFX_LINE_STYLE_THIN_SOLID);
                        GFX_LineDraw(GFX_INDEX_0,
                                                 0,  // p1x
                                                 0,  // p1y
                                                 239,   //319,  // p2x
                                                 0); // p2y
                        break;
                }               
                case Rectangle5:
                {
                        GFX_ColorSet(GFX_INDEX_0, GFX_RGBConvert(0x00, 0x00, 0xF8));
                        GFX_LineStyleSet(GFX_INDEX_0, GFX_LINE_STYLE_THIN_SOLID);
                        GFX_RectangleDraw(GFX_INDEX_0,
                                                          65-40,  // p1x
                                                          30+40,  // p1y
                                                          255-40,  // p2x
                                                          210+40); // p2y
                        
                        break;
                }       
                case Rectangle4:
                {
                        GFX_ColorSet(GFX_INDEX_0, GFX_RGBConvert(0x00, 0x00, 0xF8));
                        GFX_LineStyleSet(GFX_INDEX_0, GFX_LINE_STYLE_THIN_SOLID);
                        GFX_RectangleDraw(GFX_INDEX_0,
                                                          80-40,  // p1x
                                                          45+40,  // p1y
                                                          240-40,  // p2x
                                                          195+40); // p2y
                        
                        break;
                }       
                case Rectangle1:
                {
                        GFX_FillStyleSet(GFX_INDEX_0, GFX_FILL_STYLE_ALPHA_COLOR);
                        GFX_ColorSet(GFX_INDEX_0, GFX_RGBConvert(0xF8, 0x00, 0x00));
                        GFX_AlphaBlendingValueSet(GFX_INDEX_0, 100);
                        GFX_RectangleFillDraw(GFX_INDEX_0,
                                                                  125-40,  // p1x
                                                                  90+40,  // p1y
                                                                  195-40,  // p2x
                                                                  150+40); // p2y
                        
                        GFX_ColorSet(GFX_INDEX_0, GFX_RGBConvert(0xF8, 0x00, 0x00));
                        GFX_LineStyleSet(GFX_INDEX_0, GFX_LINE_STYLE_THIN_SOLID);
                        GFX_RectangleDraw(GFX_INDEX_0,
                                                          125-40,  // p1x
                                                          90+40,  // p1y
                                                          195-40,  // p2x
                                                          150+40); // p2y
                        
                        break;
                }       
                case Rectangle3:
                {
                        GFX_FillStyleSet(GFX_INDEX_0, GFX_FILL_STYLE_COLOR);
                        GFX_ColorSet(GFX_INDEX_0, GFX_RGBConvert(0x00, 0xFC, 0x00));
                        GFX_RectangleFillDraw(GFX_INDEX_0,
                                                                  110-40,  // p1x
                                                                  75+40,  // p1y
                                                                  210-40,  // p2x
                                                                  165+40); // p2y
                        
                        GFX_ColorSet(GFX_INDEX_0, GFX_RGBConvert(0x00, 0xFC, 0x00));
                        GFX_LineStyleSet(GFX_INDEX_0, GFX_LINE_STYLE_THIN_SOLID);
                        GFX_RectangleDraw(GFX_INDEX_0,
                                                          110-40,  // p1x
                                                          75+40,  // p1y
                                                          210-40,  // p2x
                                                          165+40); // p2y
                        
                        break;
                }       
                case Rectangle2:
                {
                        GFX_FillStyleSet(GFX_INDEX_0, GFX_FILL_STYLE_COLOR);
                        GFX_ColorSet(GFX_INDEX_0, GFX_RGBConvert(0x00, 0x00, 0xF8));
                        GFX_RectangleFillDraw(GFX_INDEX_0,
                                                                  95-40,  // p1x
                                                                  60+40,  // p1y
                                                                  225-40,  // p2x
                                                                  180+40); // p2y
                        
                        GFX_ColorSet(GFX_INDEX_0, GFX_RGBConvert(0x00, 0x00, 0xF8));
                        GFX_LineStyleSet(GFX_INDEX_0, GFX_LINE_STYLE_THIN_SOLID);
                        GFX_RectangleDraw(GFX_INDEX_0,
                                                          95-40,  // p1x
                                                          60+40,  // p1y
                                                          225-40,  // p2x
                                                          180+40); // p2y
                        
                        break;
                }       
                case Circle10:
                {
                        GFX_ColorSet(GFX_INDEX_0,GFX_RGBConvert(0xF8, 0x00, 0x00));
                        GFX_LineStyleSet(GFX_INDEX_0, GFX_LINE_STYLE_THIN_SOLID);
                        GFX_CircleDraw(GFX_INDEX_0,
                                                   120, //160, // p1x
                                                   160, //120, // p1y
                                                   3); // radius
                                                   
                        break;
                }       
                case Circle9:
                {
                        GFX_ColorSet(GFX_INDEX_0,GFX_RGBConvert(0xF8, 0x00, 0x00));
                        GFX_LineStyleSet(GFX_INDEX_0, GFX_LINE_STYLE_THIN_SOLID);
                        GFX_CircleDraw(GFX_INDEX_0,
                                                   120, //160, // p1x
                                                   160, //120, // p1y
                                                   16); // radius
                                                   
                        break;
                }       
                case Circle8:
                {
                        GFX_ColorSet(GFX_INDEX_0,GFX_RGBConvert(0xF8, 0x00, 0x00));
                        GFX_LineStyleSet(GFX_INDEX_0, GFX_LINE_STYLE_THIN_SOLID);
                        GFX_CircleDraw(GFX_INDEX_0,
                                                   120, //160, // p1x
                                                   160, //120, // p1y
                                                   29); // radius
                                                   
                        break;
                }       
                case Circle7:
                {
                        GFX_ColorSet(GFX_INDEX_0,GFX_RGBConvert(0xF8, 0x00, 0x00));
                        GFX_LineStyleSet(GFX_INDEX_0, GFX_LINE_STYLE_THIN_SOLID);
                        GFX_CircleDraw(GFX_INDEX_0,
                                                   120, //160, // p1x
                                                   160, //120, // p1y
                                                   42); // radius
                                                   
                        break;
                }       
                case Circle6:
                {
                        GFX_ColorSet(GFX_INDEX_0,GFX_RGBConvert(0xF8, 0x00, 0x00));
                        GFX_LineStyleSet(GFX_INDEX_0, GFX_LINE_STYLE_THIN_SOLID);
                        GFX_CircleDraw(GFX_INDEX_0,
                                                   120, //160, // p1x
                                                   160, //120, // p1y
                                                   55); // radius
                                                   
                        break;
                }       
                case Circle5:
                {
                        GFX_ColorSet(GFX_INDEX_0,GFX_RGBConvert(0xF8, 0x00, 0x00));
                        GFX_LineStyleSet(GFX_INDEX_0, GFX_LINE_STYLE_THIN_SOLID);
                        GFX_CircleDraw(GFX_INDEX_0,
                                                   120, //160, // p1x
                                                   160, //120, // p1y
                                                   68); // radius
                                                   
                        break;
                }       
                case Circle4:
                {
                        GFX_ColorSet(GFX_INDEX_0,GFX_RGBConvert(0xF8, 0x00, 0x00));
                        GFX_LineStyleSet(GFX_INDEX_0, GFX_LINE_STYLE_THIN_SOLID);
                        GFX_CircleDraw(GFX_INDEX_0,
                                                   120, //160, // p1x
                                                   160, //120, // p1y
                                                   81); // radius
                                                   
                        break;
                }       
                case Circle3:
                {
                        GFX_ColorSet(GFX_INDEX_0,GFX_RGBConvert(0xF8, 0x00, 0x00));
                        GFX_LineStyleSet(GFX_INDEX_0, GFX_LINE_STYLE_THIN_SOLID);
                        GFX_CircleDraw(GFX_INDEX_0,
                                                   120, //160, // p1x
                                                   160, //120, // p1y
                                                   94); // radius
                                                   
                        break;
                }       
                case Circle2:
                {
                        GFX_ColorSet(GFX_INDEX_0,GFX_RGBConvert(0xF8, 0x00, 0x00));
                        GFX_LineStyleSet(GFX_INDEX_0, GFX_LINE_STYLE_THIN_SOLID);
                        GFX_CircleDraw(GFX_INDEX_0,
                                                   120, //160, // p1x
                                                   160, //120, // p1y
                                                   107); // radius
                                                   
                        break;
                }       
                case Circle1:
                {
                        GFX_ColorSet(GFX_INDEX_0,GFX_RGBConvert(0xF8, 0x00, 0x00));
                        GFX_LineStyleSet(GFX_INDEX_0, GFX_LINE_STYLE_THIN_SOLID);
                        GFX_CircleDraw(GFX_INDEX_0,
                                                   120, //160, // p1x
                                                   160, //120, // p1y
                                                   120); // radius
                                                   
                        break;
                }       
        default:
                return false; // process by default
    }

    return true;
}

/******************************************************************************
  Function: 
    bool GFX_HGC_MsgStaticTexts(uint16_t objMsg, GFX_GOL_OBJ_HEADER *pObj)

  Output:
    Returns true if a Object ID matches an existing item identifier

  Remarks: 
    Handles GFX GOL Static Text events
 */
bool GFX_HGC_MsgStaticTexts(uint16_t objMsg, GFX_GOL_OBJ_HEADER *pObj)
{
    switch (GFX_GOL_ObjectIDGet(pObj))
    {
        default:
            return false; // default false as it is not processed
    }    
}

/******************************************************************************
  Function: 
    bool GFX_HGC_MsgPictures(uint16_t objMsg, GFX_GOL_OBJ_HEADER *pObj)

  Output:
    Returns true if a Object ID matches an existing item identifier

  Remarks: 
    Handles GFX GOL Picture Control events
 */
bool GFX_HGC_MsgPictures(uint16_t objMsg, GFX_GOL_OBJ_HEADER *pObj)
{
    switch (GFX_GOL_ObjectIDGet(pObj))
    {
        default:
            return false; // default false as it is not processed
    }    
}

 <動作結果>

1. ピクチャー
  以下、各画面

     グラフィック液晶画面 
 @  
 A  
B  

2. 動画 ---> YouTube


■ マイクロチップ デモソフト”Primitive”  at PIC32MZ + INT028
 

   
  <試作品仕様>
   ・ Harmonyのグラフィックライブラリのサンプルデモソフトとして マイクロチップから提供されている
      ”Primitive"(C:\microchip\harmony\v1_05\apps\gfx\primitive)を
     下記ハードウェアで実行する
      @ PIC: PIC32MZ2048EFH100
      A 液晶: (株)ディスプレーテック INT028 QVGA(320 x240)、2.8インチ
   
   ・ 開発環境  Harmony ver.1.06、  XC32 ver.1.40、  MPLABX 3.15  PIC32MZ2048EFH  revison 1
  

  <試作品回路図>(→回路図のPDFファイル





<試作品外観>下記の写真には上記回路図にはない、また本テーマと関係のない部品が多々写っています




          

   <プログラム例>

//以下、main.c
//------------------------------------------------------------------------------------------
/*******************************************************************************
  MPLAB Harmony Project Main Source File

  Company:
    Microchip Technology Inc.
  
  File Name:
    main.c

  Summary:
    This file contains the "main" function for an MPLAB Harmony project.

  Description:
    This file contains the "main" function for an MPLAB Harmony project.  The
    "main" function calls the "SYS_Initialize" function to initialize the state 
    machines of all MPLAB Harmony modules in the system and it calls the 
    "SYS_Tasks" function from within a system-wide "super" loop to maintain 
    their correct operation. These two functions are implemented in 
    configuration-specific files (usually "system_init.c" and "system_tasks.c")
    in a configuration-specific folder under the "src/system_config" folder 
    within this project's top-level folder.  An MPLAB Harmony project may have
    more than one configuration, each contained within it's own folder under
    the "system_config" folder.
 *******************************************************************************/

// DOM-IGNORE-BEGIN
/*******************************************************************************
Copyright (c) 2013-2014 released Microchip Technology Inc.  All rights reserved.

//Microchip licenses to you the right to use, modify, copy and distribute
Software only when embedded on a Microchip microcontroller or digital signal
controller that is integrated into your product or third party product
(pursuant to the sublicense terms in the accompanying license agreement).

You should refer to the license agreement accompanying this Software for
additional information regarding your rights and obligations.

SOFTWARE AND DOCUMENTATION ARE PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND,
EITHER EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION, ANY WARRANTY OF
MERCHANTABILITY, TITLE, NON-INFRINGEMENT AND FITNESS FOR A PARTICULAR PURPOSE.
IN NO EVENT SHALL MICROCHIP OR ITS LICENSORS BE LIABLE OR OBLIGATED UNDER
CONTRACT, NEGLIGENCE, STRICT LIABILITY, CONTRIBUTION, BREACH OF WARRANTY, OR
OTHER LEGAL EQUITABLE THEORY ANY DIRECT OR INDIRECT DAMAGES OR EXPENSES
INCLUDING BUT NOT LIMITED TO ANY INCIDENTAL, SPECIAL, INDIRECT, PUNITIVE OR
CONSEQUENTIAL DAMAGES, LOST PROFITS OR LOST DATA, COST OF PROCUREMENT OF
SUBSTITUTE GOODS, TECHNOLOGY, SERVICES, OR ANY CLAIMS BY THIRD PARTIES
(INCLUDING BUT NOT LIMITED TO ANY DEFENSE THEREOF), OR OTHER SIMILAR COSTS.
 *******************************************************************************/
// DOM-IGNORE-END


// *****************************************************************************
// *****************************************************************************
// Section: Included Files
// *****************************************************************************
// *****************************************************************************

#include <stddef.h>                     // Defines NULL
#include <stdbool.h>                    // Defines true
#include <stdlib.h>                     // Defines EXIT_FAILURE
#include "system/common/sys_module.h"   // SYS function prototypes


// *****************************************************************************
// *****************************************************************************
// Section: Main Entry Point
// *****************************************************************************
// *****************************************************************************

int main ( void )
{
    /* Initialize all MPLAB Harmony modules, including application(s). */
    SYS_Initialize ( NULL );


    while ( true )
    {
        /* Maintain state machines of all polled MPLAB Harmony modules. */
        SYS_Tasks ( );

    }

    /* Execution should not come here during normal operation */

    return ( EXIT_FAILURE );
}


/*******************************************************************************
 End of File
*/






//以下、app.c
//------------------------------------------------------------------------------------------



/*******************************************************************************
  MPLAB Harmony Application Source File
  
  Company:
    Microchip Technology Inc.
  
  File Name:
    app.c

  Summary:
    This file contains the source code for the MPLAB Harmony application.

  Description:
    This file contains the source code for the MPLAB Harmony application.  It 
    implements the logic of the application's state machine and it may call 
    API routines of other MPLAB Harmony modules in the system, such as drivers,
    system services, and middleware.  However, it does not call any of the
    system interfaces (such as the "Initialize" and "Tasks" functions) of any of
    the modules in the system or make any assumptions about when those functions
    are called.  That is the responsibility of the configuration-specific system
    files.
 *******************************************************************************/

// DOM-IGNORE-BEGIN
/*******************************************************************************
Copyright (c) 2013-2014 released Microchip Technology Inc.  All rights reserved.

Microchip licenses to you the right to use, modify, copy and distribute
Software only when embedded on a Microchip microcontroller or digital signal
controller that is integrated into your product or third party product
(pursuant to the sublicense terms in the accompanying license agreement).

You should refer to the license agreement accompanying this Software for
additional information regarding your rights and obligations.

SOFTWARE AND DOCUMENTATION ARE PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND,
EITHER EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION, ANY WARRANTY OF
MERCHANTABILITY, TITLE, NON-INFRINGEMENT AND FITNESS FOR A PARTICULAR PURPOSE.
IN NO EVENT SHALL MICROCHIP OR ITS LICENSORS BE LIABLE OR OBLIGATED UNDER
CONTRACT, NEGLIGENCE, STRICT LIABILITY, CONTRIBUTION, BREACH OF WARRANTY, OR
OTHER LEGAL EQUITABLE THEORY ANY DIRECT OR INDIRECT DAMAGES OR EXPENSES
INCLUDING BUT NOT LIMITED TO ANY INCIDENTAL, SPECIAL, INDIRECT, PUNITIVE OR
CONSEQUENTIAL DAMAGES, LOST PROFITS OR LOST DATA, COST OF PROCUREMENT OF
SUBSTITUTE GOODS, TECHNOLOGY, SERVICES, OR ANY CLAIMS BY THIRD PARTIES
(INCLUDING BUT NOT LIMITED TO ANY DEFENSE THEREOF), OR OTHER SIMILAR COSTS.
 *******************************************************************************/
// DOM-IGNORE-END


// *****************************************************************************
// *****************************************************************************
// Section: Included Files 
// *****************************************************************************
// *****************************************************************************

#include "app.h"
#include "1lcd_lib_C32.h"


int delay_Clock = 200000000;   //200MHz

void delay_us(volatile unsigned int usec)        //1μsec遅延
{
        volatile  int count;

        count = (int)(delay_Clock/20000000)*usec;


        do      //実測 at 200MH (Clock=200000000)
        {       //delay_us(1000):1000.4μsec  delay_us(100):100.6μsec  delay_us(10):10.5μsec  delay_us(1):1.5μsec
                asm("NOP"); asm("NOP"); asm("NOP"); asm("NOP"); asm("NOP");asm("NOP");
                asm("NOP"); asm("NOP"); asm("NOP"); asm("NOP"); asm("NOP"); asm("NOP");

                count--;
        }while(count != 0);


}

void delay_ms(volatile unsigned int msec)        //1msec遅延
{
        volatile unsigned int i;         //実測:at200MH (Clock=200000000)//delay_ms(1): 1.0006msec   delay_ms(100):100.04msec

        for(i=0; i<msec; i++)
        delay_us(1000);
}



// *****************************************************************************
// *****************************************************************************
// Section: Global Data Definitions
// *****************************************************************************
// *****************************************************************************

// *****************************************************************************
/* Application Data

  Summary:
    Holds application data

  Description:
    This structure holds the application's data.

  Remarks:
    This structure should be initialized by the APP_Initialize function.
    
    Application strings and buffers are be defined outside this structure.
*/

APP_DATA appData;





// *****************************************************************************
// *****************************************************************************
// Section: MACROS
// *****************************************************************************
// *****************************************************************************
#define MIN(x,y)                ((x > y)? y: x)
#define APP_SCREEN_DELAY_MS         (1000)
// *****************************************************************************
// *****************************************************************************
// Section: Global Variable Definitions
// *****************************************************************************
// *****************************************************************************

// *****************************************************************************
// *****************************************************************************
// Section: Application Local Routines
// *****************************************************************************
void APP_TMR_DelayMS ( unsigned int delayMs );


// *****************************************************************************
// *****************************************************************************
// Section: Application Callback Functions
// *****************************************************************************
// *****************************************************************************

/* TODO:  Add any necessary callback funtions.
*/

// *****************************************************************************
// *****************************************************************************
// Section: Application Local Functions
// *****************************************************************************
// *****************************************************************************

/* TODO:  Add any necessary local functions.
*/


// *****************************************************************************
// *****************************************************************************
// Section: Application Initialization and State Machine Functions
// *****************************************************************************
// *****************************************************************************

/*******************************************************************************
  Function:
    void APP_Initialize ( void )

  Remarks:
    See prototype in app.h.
 */

void APP_Initialize ( void )
{
    /* Place the App state machine in its initial state. */
    appData.state = APP_STATE_INIT;
    
    /* TODO: Initialize your application's state machine and other
     * parameters.
     */
}


/******************************************************************************
  Function:
    void APP_Tasks ( void )

  Remarks:
    See prototype in app.h.
 */

void APP_Tasks ( void )
{
    /* Check the application's current state. */
    switch ( appData.state )
    {
        /* Application's initial state. */
        case APP_STATE_INIT:
        {
            appData.state = APP_HGC_SCREEN1_DRAW;
            break;
        }
        
        case APP_HGC_SCREEN1_DRAW:
        {
            if(hgcObj.screenState != HGC_SCREEN_STATE_DISPLAY_SCREEN_screen1)
                return;
            
            GFX_HGC_ChangeScreen(screen2);
            APP_TMR_DelayMS(1000);
            appData.state = APP_HGC_SCREEN2_DRAW;
            
            break;
        }    

        case APP_HGC_SCREEN2_DRAW:
        {
            if(hgcObj.screenState != HGC_SCREEN_STATE_DISPLAY_SCREEN_screen2)
                return;
            
            GFX_HGC_ChangeScreen(screen3);
            APP_TMR_DelayMS(1000);
            appData.state = APP_HGC_SCREEN3_DRAW;
            break;
        }
        
        case APP_HGC_SCREEN3_DRAW:
        {
            if(hgcObj.screenState != HGC_SCREEN_STATE_DISPLAY_SCREEN_screen3)
                return;
            
            GFX_HGC_ChangeScreen(screen1);
            APP_TMR_DelayMS(1000);
            appData.state = APP_HGC_SCREEN1_DRAW;
            break;
        }    

        /* The default state should never be executed. */
        default:
        {
            /* TODO: Handle error in application's state machine. */
            break;
        }
    }
}

void APP_TMR_DelayMS ( unsigned int delayMs )
{
    if(delayMs)
    {
        uint32_t sysClk = SYS_CLK_FREQ;
        uint32_t t0;
        t0 = _CP0_GET_COUNT();
        while (_CP0_GET_COUNT() - t0 < (sysClk/2000)*delayMs);
    }
}

/*******************************************************************************
 End of File
 */









//以下、system_init.c
//---------------------------------------------------------------------------------
/*******************************************************************************
  System Initialization File

  File Name:
    system_init.c

  Summary:
    This file contains source code necessary to initialize the system.

  Description:
    This file contains source code necessary to initialize the system.  It
    implements the "SYS_Initialize" function, defines the configuration bits, 
    and allocates any necessary global system resources, such as the 
    sysObj structure that contains the object handles to all the MPLAB Harmony 
    module objects in the system.
 *******************************************************************************/

// DOM-IGNORE-BEGIN
/*******************************************************************************
Copyright (c) 2013-2015 released Microchip Technology Inc.  All rights reserved.

Microchip licenses to you the right to use, modify, copy and distribute
Software only when embedded on a Microchip microcontroller or digital signal
controller that is integrated into your product or third party product
(pursuant to the sublicense terms in the accompanying license agreement).

You should refer to the license agreement accompanying this Software for
additional information regarding your rights and obligations.

SOFTWARE AND DOCUMENTATION ARE PROVIDED AS IS WITHOUT WARRANTY OF ANY KIND,
EITHER EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION, ANY WARRANTY OF
MERCHANTABILITY, TITLE, NON-INFRINGEMENT AND FITNESS FOR A PARTICULAR PURPOSE.
IN NO EVENT SHALL MICROCHIP OR ITS LICENSORS BE LIABLE OR OBLIGATED UNDER
CONTRACT, NEGLIGENCE, STRICT LIABILITY, CONTRIBUTION, BREACH OF WARRANTY, OR
OTHER LEGAL EQUITABLE THEORY ANY DIRECT OR INDIRECT DAMAGES OR EXPENSES
INCLUDING BUT NOT LIMITED TO ANY INCIDENTAL, SPECIAL, INDIRECT, PUNITIVE OR
CONSEQUENTIAL DAMAGES, LOST PROFITS OR LOST DATA, COST OF PROCUREMENT OF
SUBSTITUTE GOODS, TECHNOLOGY, SERVICES, OR ANY CLAIMS BY THIRD PARTIES
(INCLUDING BUT NOT LIMITED TO ANY DEFENSE THEREOF), OR OTHER SIMILAR COSTS.
 *******************************************************************************/
// DOM-IGNORE-END


// *****************************************************************************
// *****************************************************************************
// Section: Included Files
// *****************************************************************************
// *****************************************************************************

#include "system_config.h"
#include "system_definitions.h"


// ****************************************************************************
// ****************************************************************************
// Section: Configuration Bits
// ****************************************************************************
// ****************************************************************************
// <editor-fold defaultstate="collapsed" desc="Configuration Bits">

/*** DEVCFG0 ***/

#pragma config DEBUG =      OFF
#pragma config JTAGEN =     OFF
#pragma config ICESEL =     ICS_PGx1
#pragma config TRCEN =      OFF
#pragma config BOOTISA =    MIPS32
#pragma config FECCCON =    OFF_UNLOCKED
#pragma config FSLEEP =     OFF
#pragma config DBGPER =     PG_ALL
#pragma config EJTAGBEN =   NORMAL
#pragma config CP =         OFF

/*** DEVCFG1 ***/

#pragma config FNOSC =      SPLL
#pragma config DMTINTV =    WIN_127_128
#pragma config FSOSCEN =    OFF
#pragma config IESO =       OFF
#pragma config POSCMOD =    EC
#pragma config OSCIOFNC =   OFF
#pragma config FCKSM =      CSECME
#pragma config WDTPS =      PS1048576
#pragma config WDTSPGM =    STOP
#pragma config FWDTEN =     OFF
#pragma config WINDIS =     NORMAL
#pragma config FWDTWINSZ =  WINSZ_25
#pragma config DMTCNT =     DMT31
#pragma config FDMTEN =     OFF

/*** DEVCFG2 ***/

#pragma config FPLLIDIV =   DIV_3
#pragma config FPLLRNG =    RANGE_5_10_MHZ

#pragma config FPLLICLK =   PLL_POSC
#pragma config FPLLMULT =   MUL_50
#pragma config FPLLODIV =   DIV_2
#pragma config UPLLFSEL =   FREQ_24MHZ
//#pragma config UPLLEN =     ON

/*** DEVCFG3 ***/

#pragma config USERID =     0xffff
#pragma config FMIIEN =     ON
#pragma config FETHIO =     ON
#pragma config PGL1WAY =    ON
#pragma config PMDL1WAY =   ON
#pragma config IOL1WAY =    ON
#pragma config FUSBIDIO =   ON

/*** BF1SEQ0 ***/

#pragma config TSEQ =       0xffff
#pragma config CSEQ =       0xffff
// </editor-fold>


// *****************************************************************************
// *****************************************************************************
// Section: Library/Stack Initialization Data
// *****************************************************************************
// *****************************************************************************



// *****************************************************************************
// *****************************************************************************
// Section: Driver Initialization Data
// *****************************************************************************
// *****************************************************************************


// </editor-fold>

DRV_GFX_INIT drvGfxInit =
{
    .orientation             = DISP_ORIENTATION,
    .horizontalResolution    = DISP_HOR_RESOLUTION,
    .verticalResolution      = DISP_VER_RESOLUTION,
    
/*
    .dataWidth               = DISP_DATA_WIDTH,
    .horizontalPulseWidth    = DISP_HOR_PULSE_WIDTH,
    .horizontalBackPorch     = DISP_HOR_BACK_PORCH,
    .horizontalFrontPorch    = DISP_HOR_FRONT_PORCH,
    .verticalPulseWidth      = DISP_VER_PULSE_WIDTH,
    .verticalBackPorch       = DISP_VER_BACK_PORCH,
    .verticalFrontPorch      = DISP_VER_FRONT_PORCH,
    .logicShift              = DISP_INV_LSHIFT,
    .LCDType                 = 1,
    .colorType               = 0,
    .TCON_Init               = TCON_MODULE,
 */ 
    
};





// *****************************************************************************
// *****************************************************************************
// Section: System Data
// *****************************************************************************
// *****************************************************************************

/* Structure to hold the object handles for the modules in the system. */
SYSTEM_OBJECTS sysObj;


// *****************************************************************************
// *****************************************************************************
// Section: Module Initialization Data
// *****************************************************************************
// *****************************************************************************

/*** GFX Initialization Data ***/

 const GFX_INIT gfxInit0 =
{
    .drvInitialize    = NULL,
    
   
    .drvOpen          = DRV_GFX_INT028_Open,
    .drvInterfaceSet  = DRV_GFX_INT028_InterfaceSet, 
  //  .drvOpen          = DRV_GFX_SSD1926_Open,
  //  .drvInterfaceSet  = DRV_GFX_SSD1926_InterfaceSet,
};

/*******************************************************************************
  Device Control System Service Initialization Data
  
  <editor-fold defaultstate="collapsed" 
  desc="Device Control System Service Initialization Data">
*/

const SYS_DEVCON_INIT sysDevconInit =
{
    .moduleInit = {0},
};

// </editor-fold>


// *****************************************************************************
// *****************************************************************************
// Section: Static Initialization Functions
// *****************************************************************************
// *****************************************************************************


// *****************************************************************************
// *****************************************************************************
// Section: System Initialization
// *****************************************************************************
// *****************************************************************************




void ys_PMP_Initialize(void)
{

    short pClockPeriod = 1000000000 / 100000000;
    
    // PMP setup
    PMMODE = 0;
    PMAEN = 0;
    PMCON = 0;
    PMMODEbits.MODE = 2;                // Intel 8080 master interface

    #if (PMP_DATA_SETUP_TIME == 0)
        PMMODEbits.WAITB = 0;
    #else
        if (PMP_DATA_SETUP_TIME <= pClockPeriod)
            PMMODEbits.WAITB = 0;
        else if (PMP_DATA_SETUP_TIME > pClockPeriod)
            PMMODEbits.WAITB = (PMP_DATA_SETUP_TIME / pClockPeriod) + 1;
    #endif

    #if (PMP_DATA_WAIT_TIME == 0)
        PMMODEbits.WAITM = 0;
    #else
        if (PMP_DATA_WAIT_TIME <= pClockPeriod)
            PMMODEbits.WAITM = 1;
        else if (PMP_DATA_WAIT_TIME > pClockPeriod)
            PMMODEbits.WAITM = (PMP_DATA_WAIT_TIME / pClockPeriod) + 1;
    #endif

    #if (PMP_DATA_HOLD_TIME == 0)
        PMMODEbits.WAITE = 0;
    #else
        if (PMP_DATA_HOLD_TIME <= pClockPeriod)
            PMMODEbits.WAITE = 0;
        else if (PMP_DATA_HOLD_TIME > pClockPeriod)
            PMMODEbits.WAITE = (PMP_DATA_HOLD_TIME / pClockPeriod) + 1;
    #endif

    #if defined(USE_16BIT_PMP)
    PMMODEbits.MODE16 = 1;              // 16 bit mode
    #elif defined(USE_8BIT_PMP)
    PMMODEbits.MODE16 = 0;              // 8 bit mode
    #endif

    PMCONbits.PTRDEN = 1;               // enable RD line
    PMCONbits.PTWREN = 1;               // enable WR line
    PMCONbits.PMPEN = 1;                // enable PMP

    delay_us(200);



}






/*******************************************************************************
  Function:
    void SYS_Initialize ( SYS_INIT_DATA *data )

  Summary:
    Initializes the board, services, drivers, application and other modules.

  Remarks:
    See prototype in system/common/sys_module.h.
 */

void SYS_Initialize ( void* data )
{
     
    
    /* Core Processor Initialization */
    SYS_CLK_Initialize( NULL );
    sysObj.sysDevcon = SYS_DEVCON_Initialize(SYS_DEVCON_INDEX_0, (SYS_MODULE_INIT*)&sysDevconInit);
    SYS_DEVCON_PerformanceConfig(SYS_CLK_SystemFrequencyGet());
    
    delay_ms(2000); //SYS_PORTS_Initialize(); ys_PMP_Initialize(); の前に設定のこと
    
    
    SYS_PORTS_Initialize();
    
     
   /*
    SYS_DEVCON_SystemUnlock();
    //PMP用ペリフェラルクロック低減 100MH → 25MHz
//    PB2DIVbits.PBDIV = 0b1111111;   //1/128
     PB2DIVbits.PBDIV = 0x03;  //PBCLK2 is SYSCLK divided by 4   //  PMP SPI 1/4 = 100MHz / 4 = 25MHz

    SYS_DEVCON_SystemLock();
  */  

    /* Initialize Drivers */

    /* Initialize System Services */

      delay_ms(500);  

//PMP 初期化 Initialize PMP0
    ys_PMP_Initialize();
//    DRV_PMP0_Initialize();
//    DRV_PMP0_ModeConfig();

    
//GFX グラフィック初期化
    DRV_GFX_INT028_Initialize(GFX_INDEX_0, (SYS_MODULE_INIT*)&drvGfxInit);
    //DRV_GFX_SSD1926_Initialize(GFX_INDEX_0, (SYS_MODULE_INIT*)&drvGfxInit);
   

    /* Initialize Middleware */

    sysObj.gfxObject0 = GFX_Initialize(GFX_INDEX_0, (SYS_MODULE_INIT *)&gfxInit0);  //GFX初期化
           
    /* Initialize the Application */
    APP_Initialize();
}


/*******************************************************************************
 End of File
*/






//以下、system_definitons.h
//----------------------------------------------------------------------------------

/*******************************************************************************
  System Definitions

  File Name:
    system_definitions.h

  Summary:
    MPLAB Harmony project system definitions.

  Description:
    This file contains the system-wide prototypes and definitions for an MPLAB
    Harmony project.
 *******************************************************************************/

//DOM-IGNORE-BEGIN
/*******************************************************************************
Copyright (c) 2013-2014 released Microchip Technology Inc.  All rights reserved.

Microchip licenses to you the right to use, modify, copy and distribute
Software only when embedded on a Microchip microcontroller or digital signal
controller that is integrated into your product or third party product
(pursuant to the sublicense terms in the accompanying license agreement).

You should refer to the license agreement accompanying this Software for
additional information regarding your rights and obligations.

SOFTWARE AND DOCUMENTATION ARE PROVIDED AS IS WITHOUT WARRANTY OF ANY KIND,
EITHER EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION, ANY WARRANTY OF
MERCHANTABILITY, TITLE, NON-INFRINGEMENT AND FITNESS FOR A PARTICULAR PURPOSE.
IN NO EVENT SHALL MICROCHIP OR ITS LICENSORS BE LIABLE OR OBLIGATED UNDER
CONTRACT, NEGLIGENCE, STRICT LIABILITY, CONTRIBUTION, BREACH OF WARRANTY, OR
OTHER LEGAL EQUITABLE THEORY ANY DIRECT OR INDIRECT DAMAGES OR EXPENSES
INCLUDING BUT NOT LIMITED TO ANY INCIDENTAL, SPECIAL, INDIRECT, PUNITIVE OR
CONSEQUENTIAL DAMAGES, LOST PROFITS OR LOST DATA, COST OF PROCUREMENT OF
SUBSTITUTE GOODS, TECHNOLOGY, SERVICES, OR ANY CLAIMS BY THIRD PARTIES
(INCLUDING BUT NOT LIMITED TO ANY DEFENSE THEREOF), OR OTHER SIMILAR COSTS.
 *******************************************************************************/
//DOM-IGNORE-END

#ifndef _SYS_DEFINITIONS_H
#define _SYS_DEFINITIONS_H


// *****************************************************************************
// *****************************************************************************
// Section: Included Files
// *****************************************************************************
// *****************************************************************************

#include <stdint.h>
#include <stddef.h>
#include <stdbool.h>
#include "system/common/sys_common.h"
#include "system/common/sys_module.h"
#include "system/clk/sys_clk.h"
#include "system/clk/sys_clk_static.h"
#include "system/devcon/sys_devcon.h"
#include "system/console/sys_console.h"

#include "framework/driver/pmp/drv_pmp_static.h"
#include "driver/tmr/drv_tmr_static.h"
#include "peripheral/int/plib_int.h"
#include "system/ports/sys_ports.h"
#include "gfx/gfx.h"
#include "gfx/gfx_gol.h"
#include "gfx/gfx_gol_scheme.h"


#include "drv_gfx_INT028_24_22.h"     //INT028, INT024, INT022用
//#include "driver/gfx/controller/ssd1926/drv_gfx_ssd1926.h"
#include "system/debug/sys_debug.h"
#include "system/command/sys_command.h"


#include "gfx_hgc_definitions.h"
#include "app.h"


// *****************************************************************************
// *****************************************************************************
// Section: Type Definitions
// *****************************************************************************
// *****************************************************************************

// *****************************************************************************
/* System Objects

  Summary:
    Structure holding the system's object handles

  Description:
    This structure contains the object handles for all objects in the
    MPLAB Harmony project's system configuration.

  Remarks:
    These handles are returned from the "Initialize" functions for each module
    and must be passed into the "Tasks" function for each module.
*/

typedef struct
{
    SYS_MODULE_OBJ  sysDevcon;
    SYS_MODULE_OBJ  gfxObject0;
    
} SYSTEM_OBJECTS;


// *****************************************************************************
// *****************************************************************************
// Section: extern declarations
// *****************************************************************************
// *****************************************************************************

extern SYSTEM_OBJECTS sysObj;

#endif /* _SYS_DEFINITIONS_H */
/*******************************************************************************
 End of File
*/




//以下、gfx_hgc_definitions.h
//--------------------------------------------------------------------------

/*******************************************************************************
  MPLAB Harmony Graphics Composer Generated Definitions Header

  File Name:
    gfx_hgc_definitions.h

  Summary:
    Build-time generated definitions header based on output by the MPLAB Harmony
    Graphics Composer.

  Description:
    Build-time generated definitions header based on output by the MPLAB Harmony
    Graphics Composer.

    Created with MPLAB Harmony Version 1.05
*******************************************************************************/

// DOM-IGNORE-BEGIN
/*******************************************************************************
Copyright (c) 2013-2014 released Microchip Technology Inc.  All rights reserved.

Microchip licenses to you the right to use, modify, copy and distribute
Software only when embedded on a Microchip microcontroller or digital signal
controller that is integrated into your product or third party product
(pursuant to the sublicense terms in the accompanying license agreement).

You should refer to the license agreement accompanying this Software for
additional information regarding your rights and obligations.

SOFTWARE AND DOCUMENTATION ARE PROVIDED AS IS WITHOUT WARRANTY OF ANY KIND,
EITHER EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION, ANY WARRANTY OF
MERCHANTABILITY, TITLE, NON-INFRINGEMENT AND FITNESS FOR A PARTICULAR PURPOSE.
IN NO EVENT SHALL MICROCHIP OR ITS LICENSORS BE LIABLE OR OBLIGATED UNDER
CONTRACT, NEGLIGENCE, STRICT LIABILITY, CONTRIBUTION, BREACH OF WARRANTY, OR
OTHER LEGAL EQUITABLE THEORY ANY DIRECT OR INDIRECT DAMAGES OR EXPENSES
INCLUDING BUT NOT LIMITED TO ANY INCIDENTAL, SPECIAL, INDIRECT, PUNITIVE OR
CONSEQUENTIAL DAMAGES, LOST PROFITS OR LOST DATA, COST OF PROCUREMENT OF
SUBSTITUTE GOODS, TECHNOLOGY, SERVICES, OR ANY CLAIMS BY THIRD PARTIES
(INCLUDING BUT NOT LIMITED TO ANY DEFENSE THEREOF), OR OTHER SIMILAR COSTS.
*******************************************************************************/
// DOM-IGNORE-END


#ifndef _GFX_HGC_DEFINITIONS_H
#define _GFX_HGC_DEFINITIONS_H

#include "system_config.h"
#include "system_definitions.h"

typedef enum
{
    HGC_STATE_INIT = 0,
    HGC_STATE_RUNNING
} HGC_STATES;

typedef enum
{
    HGC_SCREEN_STATE_INIT = 0,
    HGC_SCREEN_STATE_SETUP_SCREEN_screen1,
    HGC_SCREEN_STATE_PRE_DRAW_GOL_SCREEN_screen1,
    HGC_SCREEN_STATE_DRAW_GOL_SCREEN_screen1,
    HGC_SCREEN_STATE_POST_DRAW_GOL_SCREEN_screen1,
    HGC_SCREEN_STATE_PRE_DRAW_PRIMITIVE_SCREEN_screen1,
    HGC_SCREEN_STATE_DRAW_PRIMITIVE_SCREEN_screen1,
    HGC_SCREEN_STATE_POST_DRAW_PRIMITIVE_SCREEN_screen1,
    HGC_SCREEN_STATE_DISPLAY_SCREEN_screen1,
        
    HGC_SCREEN_STATE_SETUP_SCREEN_screen2,
    HGC_SCREEN_STATE_PRE_DRAW_GOL_SCREEN_screen2,
    HGC_SCREEN_STATE_DRAW_GOL_SCREEN_screen2,
    HGC_SCREEN_STATE_POST_DRAW_GOL_SCREEN_screen2,
    HGC_SCREEN_STATE_PRE_DRAW_PRIMITIVE_SCREEN_screen2,
    HGC_SCREEN_STATE_DRAW_PRIMITIVE_SCREEN_screen2,
    HGC_SCREEN_STATE_POST_DRAW_PRIMITIVE_SCREEN_screen2,
    HGC_SCREEN_STATE_DISPLAY_SCREEN_screen2,
        
    HGC_SCREEN_STATE_SETUP_SCREEN_screen3,
    HGC_SCREEN_STATE_PRE_DRAW_GOL_SCREEN_screen3,
    HGC_SCREEN_STATE_DRAW_GOL_SCREEN_screen3,
    HGC_SCREEN_STATE_POST_DRAW_GOL_SCREEN_screen3,
    HGC_SCREEN_STATE_PRE_DRAW_PRIMITIVE_SCREEN_screen3,
    HGC_SCREEN_STATE_DRAW_PRIMITIVE_SCREEN_screen3,
    HGC_SCREEN_STATE_POST_DRAW_PRIMITIVE_SCREEN_screen3,
    HGC_SCREEN_STATE_DISPLAY_SCREEN_screen3,
        
} HGC_SCREEN_STATES;

/*** GFX GOL Scheme Definitions ***/

#define GFX_SCHEME_NAME_0                       "default"
#define GFX_SCHEME_ALPHA_0                      100

#define GFX_SCHEME_BACKGROUND_OFFSET_TOP_0      0
#define GFX_SCHEME_BACKGROUND_OFFSET_LEFT_0     0

#define GFX_SCHEME_PRIMARY_COLOR_RED_0          0x00
#define GFX_SCHEME_PRIMARY_COLOR_GREEN_0        0x00
#define GFX_SCHEME_PRIMARY_COLOR_BLUE_0         0x00

#define GFX_SCHEME_SECONDARY_COLOR_RED_0        0x40
#define GFX_SCHEME_SECONDARY_COLOR_GREEN_0      0x40
#define GFX_SCHEME_SECONDARY_COLOR_BLUE_0       0x40

#define GFX_SCHEME_DISABLED_COLOR_RED_0         0x00
#define GFX_SCHEME_DISABLED_COLOR_GREEN_0       0x00
#define GFX_SCHEME_DISABLED_COLOR_BLUE_0        0x00

#define GFX_SCHEME_BACKGROUND_COLOR_RED_0       0x00
#define GFX_SCHEME_BACKGROUND_COLOR_GREEN_0     0x00
#define GFX_SCHEME_BACKGROUND_COLOR_BLUE_0      0x00

#define GFX_SCHEME_EMBOSS_SIZE_0                3

#define GFX_SCHEME_EMBOSS_LIGHT_COLOR_RED_0     0x00
#define GFX_SCHEME_EMBOSS_LIGHT_COLOR_GREEN_0   0x00
#define GFX_SCHEME_EMBOSS_LIGHT_COLOR_BLUE_0    0x00

#define GFX_SCHEME_EMBOSS_DARK_COLOR_RED_0      0x00
#define GFX_SCHEME_EMBOSS_DARK_COLOR_GREEN_0    0x00
#define GFX_SCHEME_EMBOSS_DARK_COLOR_BLUE_0     0x00

#define GFX_SCHEME_TEXT_PRIMARY_COLOR_RED_0     0xF8
#define GFX_SCHEME_TEXT_PRIMARY_COLOR_GREEN_0   0xFC
#define GFX_SCHEME_TEXT_PRIMARY_COLOR_BLUE_0    0xF8

#define GFX_SCHEME_TEXT_SECONDARY_COLOR_RED_0   0x00
#define GFX_SCHEME_TEXT_SECONDARY_COLOR_GREEN_0 0x00
#define GFX_SCHEME_TEXT_SECONDARY_COLOR_BLUE_0  0x00

#define GFX_SCHEME_TEXT_DISABLED_COLOR_RED_0    0x40
#define GFX_SCHEME_TEXT_DISABLED_COLOR_GREEN_0  0x40
#define GFX_SCHEME_TEXT_DISABLED_COLOR_BLUE_0   0x40

#define GFX_SCHEME_GRADIENT_START_COLOR_RED_0    0x00
#define GFX_SCHEME_GRADIENT_START_COLOR_GREEN_0  0x00
#define GFX_SCHEME_GRADIENT_START_COLOR_BLUE_0   0x00

#define GFX_SCHEME_GRADIENT_END_COLOR_RED_0    0x00
#define GFX_SCHEME_GRADIENT_END_COLOR_GREEN_0  0x00
#define GFX_SCHEME_GRADIENT_END_COLOR_BLUE_0   0x00

#define GFX_SCHEME_FILL_STYLE_0                GFX_FILL_STYLE_COLOR
#define GFX_SCHEME_BACKGROUND_TYPE_0           GFX_BACKGROUND_NONE

                
/*** GFX GOL Button Definitions ***/
#define GFX_STATICTEXT_LEFT_0            13
#define GFX_STATICTEXT_TOP_0             141
#define GFX_STATICTEXT_RIGHT_0           131
#define GFX_STATICTEXT_BOTTOM_0          191
#define GFX_STATICTEXT_STATE_0          GFX_GOL_STATICTEXT_DRAW_STATE
#define GFX_STATICTEXT_TEXT_0            "0x31, 0x36, 0x62, 0x69, 0x74, 0x20, 0x42, 0x50, 0x50, 0x0"
#define GFX_STATICTEXT_ALIGNMENT_0       GFX_ALIGN_LEFT | GFX_ALIGN_TOP
#define GFX_STATICTEXT_SCHEME_0          gfxScheme0
                
/*** static text IDs ***/
#define StaticText1                  700 
        
/*** GFX GOL windows Definitions ***/
#define GFX_PICTURE_LEFT_0            7
#define GFX_PICTURE_TOP_0             8
#define GFX_PICTURE_RIGHT_0           107
#define GFX_PICTURE_BOTTOM_0          137
#define GFX_PICTURE_STATE_0          GFX_GOL_PICTURECONTROL_DRAW_STATE
#define GFX_PICTURE_SCALE_0       1
#define GFX_PICTURE_SCHEME_0          gfxScheme0
                
/*** Pictures IDs ***/
#define Picture1                  800 
        
/*** Line IDs ***/
#define Line11                 950 
        
#define Line10                 951 
        
#define Line9                 952 
        
#define Line8                 953 
        
#define Line7                 954 
        
#define Line6                 955 
        
#define Line5                 956 
        
#define Line4                 957 
        
#define Line3                 958 
        
#define Line2                 959 
        
#define Line1                 960 
        
/*** Rectangle IDs ***/
#define Rectangle5                 1000 
        
#define Rectangle4                 1001 
        
#define Rectangle1                 1002 
        
#define Rectangle3                 1003 
        
#define Rectangle2                 1004 
        
/*** Circle IDs ***/
#define Circle10                 1050 

#define Circle9                 1051 
        
#define Circle8                 1052 
        
#define Circle7                 1053 
        
#define Circle6                 1054 
        
#define Circle5                 1055 
        
#define Circle4                 1056 
        
#define Circle3                 1057 
        
#define Circle2                 1058 
        
#define Circle1                 1059 
        
/*** Screen IDs ***/
#define screen1                 0 
        
#define screen2                 1 

#define screen3                 2 



// *****************************************************************************
/* MPLAB Harmony Graphics Composer Objects

  Summary:
    Structure holding the graphics object handles

  Description:
    This structure contains the object handles for all graphics objects 
    generated by the Harmony Graphics Composer

  Remarks:
*/

typedef struct HGC_OBJECTS
{
    HGC_SCREEN_STATES screenState;      // current state of screen state machine
    HGC_SCREEN_STATES prevRefreshState; // previous state of screen state machine

//    DRV_TOUCH_SAMPLE_POINTS samplePoints;

    /*** GOL Objects References ***/
    GFX_GOL_STATICTEXT* pStaticText1Obj;
    GFX_GOL_PICTURECONTROL* pPicture1Obj;
} HGC_OBJECTS;

extern HGC_OBJECTS hgcObj;

/******************************************************************************
  Function:
    void GFX_HGC_Setup ( void )

  Summary:
    This function sets up the GOL message callback and draw callbacks.  
 */
void GFX_HGC_Setup ( void );


/******************************************************************************
  Function:
    HGC_SCREEN_STATES GFX_HGC_GetScreenState ( void )

  Remarks:
    This function returns the screen state
 */
HGC_SCREEN_STATES GFX_HGC_GetScreenState ( void );


/******************************************************************************
  Function:
    void GFX_HGC_SetScreenState ( HGC_SCREEN_STATES newState )

  Remarks:
    This function sets the screen state machine to a new state
 */
void GFX_HGC_SetScreenState ( HGC_SCREEN_STATES newState );


/******************************************************************************
  Function:
    void GFX_HGC_Tasks (SYS_MODULE_OBJ gfxObject);

  Summary:
    This function is called in SYS_Tasks.  The intent wait until the GFX library
    is initialized before supplying items to draw
*/
void GFX_HGC_Tasks  (SYS_MODULE_OBJ gfxObject);


/******************************************************************************
  Function:
    void GFX_HGC_SchemeCreate ( void )

  Summary:
    Allocates memory for a new scheme
 */
GFX_GOL_OBJ_SCHEME *GFX_HGC_SchemeCreate(void);


/******************************************************************************
  Function:
    void GFX_HGC_InitializeSchemes ( void )

  Summary:
    Initializes all HGC-specified schemes
 */
void GFX_HGC_InitializeSchemes( void );


/******************************************************************************
  Function: 
    bool GFX_HGC_MESSAGECallback(uint16_t objMsg, GFX_GOL_OBJ_HEADER* pObj, GFX_GOL_MESSAGE* pMsg)

  Input: 
    objMsg - translated message for the object,
    pObj - pointer to the object,
    pMsg - pointer to the non-translated, raw GOL message

  Output: 
    If the function returns non-zero the message will be processed by default

  Remarks: 
    GFX_GOL_MESSAGECallback() function calls it each time the valid message for the GOL object is received.
 */
bool GFX_HGC_MessageCallback(GFX_GOL_TRANSLATED_ACTION objMsg, GFX_GOL_OBJ_HEADER *pObj, GFX_GOL_MESSAGE *pMsg);


/******************************************************************************
  Function: 
    bool GFX_HGC_DrawCallback( void )

  Output: 
    If the function returns non-zero the draw control will be passed to GOL

  Remarks: 
    GFX_GOL_Draw() function calls it each time when GOL objects drawing is 
    completed. HGC-specified draw data is grouped by screens states. It takes 
    two states to complete the drawing of each screen.  GFX GOL objects are drawn
    first and then GFX Primitives are drawn next to ensure primitives are not
    covered by GOL objects.
 */
bool GFX_HGC_DrawCallback( void );
/******************************************************************************
  Function: 
    bool GFX_HGC_DrawScreen_GOL( uint8_t  screenId )

  Output: 
    Returns true if a screenId matches an existing screen identifier

  Remarks: 
    HGC-specified GFX GOL objects are drawn here, grouped by screen.
    The draw order is reverse Z-ordered.
 */
bool GFX_HGC_DrawScreen_GOL(uint8_t screenId);


/******************************************************************************
  Function: 
    bool GFX_HGC_DrawScreen_Primitives( uint8_t  screenId )

  Output:
    Returns true if a screenId matches an existing screen identifier

  Remarks: 
    HGC-specified GFX Primitives are drawn here, grouped by screen.
    GFX Primitives are drawn after GFX GOL Objects to make sure GFX GOL Objects
    do not cover GFX Primitives
 */
bool GFX_HGC_DrawScreen_Primitives(uint8_t screenId);


/******************************************************************************
  Function: 
    void GFX_HGC_SetupScreen( uint8_t  screenId )

  Remarks: 
    Clears current screen and starts a fresh screen with its background color
 */
void GFX_HGC_SetupScreen(uint8_t screenId);


/******************************************************************************
  Function: 
    bool GFX_HGC_ChangeScreen( uint8_t  screenId )

  Output: 
    Returns true if a screenId matches an existing screen identifier

  Remarks: 
    Can be called to initiate GFX Library to draw a new screen
 */
bool GFX_HGC_ChangeScreen(uint8_t screenId);


/******************************************************************************
  Function: 
    bool GFX_HGC_DrawItem(int itemId)

  Output:
    Returns true if a itemId matches an existing item identifier

  Remarks: 
    Every item specified in every screen in HGC is listed in this function
 */
bool GFX_HGC_DrawItem(int itemId);


/******************************************************************************
  Function: 
    bool GFX_HGC_MsgPictures(uint16_t objMsg, GFX_GOL_OBJ_HEADER *pObj)

  Output:
    Returns true if a Object ID matches an existing item identifier

  Remarks: 
    Handles GFX GOL Picture Control events
 */
bool GFX_HGC_MsgPictures(uint16_t objMsg, GFX_GOL_OBJ_HEADER *pObj);

/******************************************************************************
  Function: 
    bool GFX_HGC_MsgStaticTexts(uint16_t objMsg, GFX_GOL_OBJ_HEADER *pObj)

  Output:
    Returns true if a Object ID matches an existing item identifier

  Remarks: 
    Handles GFX GOL Static Text events
 */
bool GFX_HGC_MsgStaticTexts(uint16_t objMsg, GFX_GOL_OBJ_HEADER *pObj);

#endif // _GFX_HGC_DEFINITIONS_H
/*******************************************************************************
 End of File
*/



//以下、gfx_hgc_definitions.c
//-------------------------------------------------------------------------
/*******************************************************************************
  MPLAB Harmony Graphics Composer Generated Implementation File

  File Name:
    gfx_hgc_definitions.c

  Summary:
    Build-time generated implementation from the MPLAB Harmony
    Graphics Composer.

  Description:
    Build-time generated implementation from the MPLAB Harmony
    Graphics Composer.

    Created with MPLAB Harmony Version 1.05
*******************************************************************************/
// DOM-IGNORE-BEGIN
/*******************************************************************************
Copyright (c) 2013-2014 released Microchip Technology Inc.  All rights reserved.

Microchip licenses to you the right to use, modify, copy and distribute
Software only when embedded on a Microchip microcontroller or digital signal
controller that is integrated into your product or third party product
(pursuant to the sublicense terms in the accompanying license agreement).

You should refer to the license agreement accompanying this Software for
additional information regarding your rights and obligations.

SOFTWARE AND DOCUMENTATION ARE PROVIDED AS IS WITHOUT WARRANTY OF ANY KIND,
EITHER EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION, ANY WARRANTY OF
MERCHANTABILITY, TITLE, NON-INFRINGEMENT AND FITNESS FOR A PARTICULAR PURPOSE.
IN NO EVENT SHALL MICROCHIP OR ITS LICENSORS BE LIABLE OR OBLIGATED UNDER
CONTRACT, NEGLIGENCE, STRICT LIABILITY, CONTRIBUTION, BREACH OF WARRANTY, OR
OTHER LEGAL EQUITABLE THEORY ANY DIRECT OR INDIRECT DAMAGES OR EXPENSES
INCLUDING BUT NOT LIMITED TO ANY INCIDENTAL, SPECIAL, INDIRECT, PUNITIVE OR
CONSEQUENTIAL DAMAGES, LOST PROFITS OR LOST DATA, COST OF PROCUREMENT OF
SUBSTITUTE GOODS, TECHNOLOGY, SERVICES, OR ANY CLAIMS BY THIRD PARTIES
(INCLUDING BUT NOT LIMITED TO ANY DEFENSE THEREOF), OR OTHER SIMILAR COSTS.
*******************************************************************************/
// DOM-IGNORE-END

#include "gfx_hgc_definitions.h"

/*** Default GFX GOL Scheme ***/
#define GFX_SCHEMEDEFAULT GOLSchemeDefault
extern GFX_GOL_OBJ_SCHEME GFX_SCHEMEDEFAULT;

/*** HGC-specified GFX GOL Scheme ***/
static GFX_GOL_OBJ_SCHEME *gfxScheme0;

/*** Generated Asset References ***/
extern const GFX_RESOURCE_HDR flower16bit;
extern const GFX_RESOURCE_HDR fireflysung;

/*** Generated ASCII Text Labels ***/
static const GFX_XCHAR staticTextStr_0[] = { 0x31, 0x36, 0x62, 0x69, 0x74, 0x20, 0x42, 0x50, 0x50, 0x0 }; // 16bit BPP
/*** HGC Object Global ***/
HGC_OBJECTS hgcObj;
static HGC_STATES hgcState;

/******************************************************************************
  Function:
    HGC_SCREEN_STATES GFX_HGC_GetScreenState ( void )

  Remarks:
    This function returns the screen state
 */
HGC_SCREEN_STATES GFX_HGC_GetScreenState ( void )
{
    return hgcObj.screenState;
}


/******************************************************************************
  Function:
    void GFX_HGC_SetScreenState ( HGC_SCREEN_STATES newState )

  Remarks:
    This function sets the screen state machine to a new state
 */
void GFX_HGC_SetScreenState ( HGC_SCREEN_STATES newState )
{
    hgcObj.prevRefreshState = hgcObj.screenState;
    hgcObj.screenState = newState;
}


/******************************************************************************
  Function:
    void GFX_HGC_Setup ( void )

  Summary:
    This function sets up the GOL message callback and draw callbacks.  
 */
void GFX_HGC_Setup ( void )
{
    GFX_GOL_MessageCallbackSet(GFX_INDEX_0, &GFX_HGC_MessageCallback);
    GFX_GOL_DrawCallbackSet(GFX_INDEX_0, &GFX_HGC_DrawCallback);

    GFX_HGC_InitializeSchemes();

}

/******************************************************************************
  Function:
    void GFX_HGC_Tasks (SYS_MODULE_OBJ gfxObject);

  Summary:
    This function is called in SYS_Tasks.  The intent wait until the GFX library
    is initialized before supplying items to draw
*/
void GFX_HGC_Tasks  (SYS_MODULE_OBJ gfxObject)
{
    switch ( hgcState )
    {
        case HGC_STATE_INIT:
            if (GFX_Status(gfxObject)==SYS_STATUS_READY)
            {
                GFX_HGC_Setup();
                hgcState = HGC_STATE_RUNNING;
            }
            break;

        case HGC_STATE_RUNNING:
            break;

        default:
            break;
    }
}

/******************************************************************************
  Function:
    void GFX_HGC_SchemeCreate ( void )

  Summary:
    Allocates memory for a new scheme
 */
GFX_GOL_OBJ_SCHEME *GFX_HGC_SchemeCreate(void)
{
    GFX_GOL_OBJ_SCHEME  *pTemp;

    pTemp = (GFX_GOL_OBJ_SCHEME *)GFX_malloc(sizeof(GFX_GOL_OBJ_SCHEME));

    if(pTemp != NULL)
    {
        memcpy(pTemp, &GFX_SCHEMEDEFAULT, sizeof(GFX_GOL_OBJ_SCHEME));
    }

    return (pTemp);
}

/******************************************************************************
  Function:
    void GFX_HGC_InitializeSchemes ( void )

  Summary:
    Initializes all HGC-specified schemes
 */
void GFX_HGC_InitializeSchemes( void )
{
    gfxScheme0 = GFX_HGC_SchemeCreate();

#ifndef GFX_CONFIG_ALPHABLEND_DISABLE
    gfxScheme0->AlphaValue =        GFX_SCHEME_ALPHA_0;
#endif
    gfxScheme0->Color0 =            GFX_RGBConvert(GFX_SCHEME_PRIMARY_COLOR_RED_0, GFX_SCHEME_PRIMARY_COLOR_GREEN_0, GFX_SCHEME_PRIMARY_COLOR_BLUE_0);
    gfxScheme0->Color1 =            GFX_RGBConvert(GFX_SCHEME_SECONDARY_COLOR_RED_0, GFX_SCHEME_SECONDARY_COLOR_GREEN_0, GFX_SCHEME_SECONDARY_COLOR_BLUE_0);
    gfxScheme0->ColorDisabled =     GFX_RGBConvert(GFX_SCHEME_DISABLED_COLOR_RED_0, GFX_SCHEME_DISABLED_COLOR_GREEN_0, GFX_SCHEME_DISABLED_COLOR_BLUE_0);
    gfxScheme0->CommonBkColor =     GFX_RGBConvert(GFX_SCHEME_BACKGROUND_COLOR_RED_0, GFX_SCHEME_BACKGROUND_COLOR_GREEN_0, GFX_SCHEME_BACKGROUND_COLOR_BLUE_0);
        gfxScheme0->EmbossSize =        GFX_SCHEME_EMBOSS_SIZE_0;
    gfxScheme0->EmbossDkColor =     GFX_RGBConvert(GFX_SCHEME_EMBOSS_DARK_COLOR_RED_0, GFX_SCHEME_EMBOSS_DARK_COLOR_GREEN_0, GFX_SCHEME_EMBOSS_DARK_COLOR_BLUE_0);
    gfxScheme0->EmbossLtColor =     GFX_RGBConvert(GFX_SCHEME_EMBOSS_LIGHT_COLOR_RED_0, GFX_SCHEME_EMBOSS_LIGHT_COLOR_GREEN_0, GFX_SCHEME_EMBOSS_LIGHT_COLOR_BLUE_0);
        gfxScheme0->TextColor0 =        GFX_RGBConvert(GFX_SCHEME_TEXT_PRIMARY_COLOR_RED_0, GFX_SCHEME_TEXT_PRIMARY_COLOR_GREEN_0, GFX_SCHEME_TEXT_PRIMARY_COLOR_BLUE_0);
    gfxScheme0->TextColor1 =        GFX_RGBConvert(GFX_SCHEME_TEXT_SECONDARY_COLOR_RED_0, GFX_SCHEME_TEXT_SECONDARY_COLOR_GREEN_0, GFX_SCHEME_TEXT_SECONDARY_COLOR_BLUE_0);
    gfxScheme0->TextColorDisabled = GFX_RGBConvert(GFX_SCHEME_TEXT_DISABLED_COLOR_RED_0, GFX_SCHEME_TEXT_DISABLED_COLOR_GREEN_0, GFX_SCHEME_TEXT_DISABLED_COLOR_BLUE_0);
#ifndef GFX_CONFIG_GRADIENT_DISABLE
        gfxScheme0->gradientStartColor = GFX_RGBConvert(GFX_SCHEME_GRADIENT_START_COLOR_RED_0, GFX_SCHEME_GRADIENT_START_COLOR_GREEN_0, GFX_SCHEME_GRADIENT_START_COLOR_BLUE_0);
        gfxScheme0->gradientEndColor = GFX_RGBConvert(GFX_SCHEME_GRADIENT_END_COLOR_RED_0, GFX_SCHEME_GRADIENT_END_COLOR_GREEN_0, GFX_SCHEME_GRADIENT_END_COLOR_BLUE_0);
#endif
    gfxScheme0->CommonBkLeft =      GFX_SCHEME_BACKGROUND_OFFSET_TOP_0;
    gfxScheme0->CommonBkTop =       GFX_SCHEME_BACKGROUND_OFFSET_LEFT_0;
    gfxScheme0->pFont =             (GFX_RESOURCE_HDR*)&fireflysung;
    gfxScheme0->pCommonBkImage =    (GFX_RESOURCE_HDR*)NULL;
        
        gfxScheme0->fillStyle =         GFX_SCHEME_FILL_STYLE_0;
        gfxScheme0->CommonBkType =      GFX_SCHEME_BACKGROUND_TYPE_0;

}

/******************************************************************************
  Function: 
    bool GFX_HGC_MESSAGECallback(uint16_t objMsg, GFX_GOL_OBJ_HEADER* pObj, GFX_GOL_MESSAGE* pMsg)

  Input: 
    objMsg - translated message for the object,
    pObj - pointer to the object,
    pMsg - pointer to the non-translated, raw GOL message

  Output: 
    If the function returns non-zero the message will be processed by default

  Remarks: 
    GFX_GOL_MESSAGECallback() function calls it each time the valid message for the GOL object is received.
 */
bool GFX_HGC_MessageCallback(GFX_GOL_TRANSLATED_ACTION objMsg, GFX_GOL_OBJ_HEADER *pObj, GFX_GOL_MESSAGE *pMsg)
{
    // process messages for demo screens
    switch (hgcObj.screenState)
    {
        case HGC_SCREEN_STATE_DISPLAY_SCREEN_screen1:
            if (GFX_HGC_MsgPictures(objMsg, pObj) == true)
                return true;
            if (GFX_HGC_MsgStaticTexts(objMsg, pObj) == true)
                return true;
            break;
        case HGC_SCREEN_STATE_DISPLAY_SCREEN_screen2:
            if (GFX_HGC_MsgPictures(objMsg, pObj) == true)
                return true;
            if (GFX_HGC_MsgStaticTexts(objMsg, pObj) == true)
                return true;
            break;
        case HGC_SCREEN_STATE_DISPLAY_SCREEN_screen3:
            if (GFX_HGC_MsgPictures(objMsg, pObj) == true)
                return true;
            if (GFX_HGC_MsgStaticTexts(objMsg, pObj) == true)
                return true;
            break;
      default:
            // process message by default
            return true;
    }
    return true;
}

/******************************************************************************
  Function: 
    bool GFX_HGC_DrawCallback( void )

  Output: 
    If the function returns non-zero the draw control will be passed to GOL

  Remarks: 
    GFX_GOL_Draw() function calls it each time when GOL objects drawing is 
    completed. HGC-specified draw data is grouped by screens states. It takes 
    two states to complete the drawing of each screen.  GFX GOL objects are drawn
    first and then GFX Primitives are drawn next to ensure primitives are not
    covered by GOL objects.
 */
bool GFX_HGC_DrawCallback( void )
{
    switch (hgcObj.screenState)
    {
        case HGC_SCREEN_STATE_INIT:
            //Draw the primary screen as selected in the Composer
            GFX_HGC_SetScreenState(HGC_SCREEN_STATE_SETUP_SCREEN_screen1);
            return true;
        case HGC_SCREEN_STATE_SETUP_SCREEN_screen1:
            GFX_HGC_SetScreenState(HGC_SCREEN_STATE_PRE_DRAW_GOL_SCREEN_screen1);
            break;
        case HGC_SCREEN_STATE_PRE_DRAW_GOL_SCREEN_screen1:
            GFX_HGC_SetScreenState(HGC_SCREEN_STATE_DRAW_GOL_SCREEN_screen1);
            break;
        case HGC_SCREEN_STATE_DRAW_GOL_SCREEN_screen1:
            GFX_HGC_SetupScreen(screen1);
            GFX_HGC_DrawScreen_GOL(screen1);
            GFX_HGC_SetScreenState(HGC_SCREEN_STATE_POST_DRAW_GOL_SCREEN_screen1);
            break;
        case HGC_SCREEN_STATE_POST_DRAW_GOL_SCREEN_screen1:
            GFX_HGC_SetScreenState(HGC_SCREEN_STATE_PRE_DRAW_PRIMITIVE_SCREEN_screen1);
            break;
        case HGC_SCREEN_STATE_PRE_DRAW_PRIMITIVE_SCREEN_screen1:
            GFX_HGC_SetScreenState(HGC_SCREEN_STATE_DRAW_PRIMITIVE_SCREEN_screen1);
            break;
        case HGC_SCREEN_STATE_DRAW_PRIMITIVE_SCREEN_screen1:
            GFX_HGC_DrawScreen_Primitives(screen1);
            GFX_HGC_SetScreenState(HGC_SCREEN_STATE_POST_DRAW_PRIMITIVE_SCREEN_screen1);
            break;
        case HGC_SCREEN_STATE_POST_DRAW_PRIMITIVE_SCREEN_screen1:
            GFX_HGC_SetScreenState(HGC_SCREEN_STATE_DISPLAY_SCREEN_screen1);
            break;
        case HGC_SCREEN_STATE_DISPLAY_SCREEN_screen1:
            break;
        case HGC_SCREEN_STATE_SETUP_SCREEN_screen2:
            GFX_HGC_SetScreenState(HGC_SCREEN_STATE_PRE_DRAW_GOL_SCREEN_screen2);
            break;
        case HGC_SCREEN_STATE_PRE_DRAW_GOL_SCREEN_screen2:
            GFX_HGC_SetScreenState(HGC_SCREEN_STATE_DRAW_GOL_SCREEN_screen2);
            break;
        case HGC_SCREEN_STATE_DRAW_GOL_SCREEN_screen2:
            GFX_HGC_SetupScreen(screen2);
            GFX_HGC_DrawScreen_GOL(screen2);
            GFX_HGC_SetScreenState(HGC_SCREEN_STATE_POST_DRAW_GOL_SCREEN_screen2);
            break;
        case HGC_SCREEN_STATE_POST_DRAW_GOL_SCREEN_screen2:
            GFX_HGC_SetScreenState(HGC_SCREEN_STATE_PRE_DRAW_PRIMITIVE_SCREEN_screen2);
            break;
        case HGC_SCREEN_STATE_PRE_DRAW_PRIMITIVE_SCREEN_screen2:
            GFX_HGC_SetScreenState(HGC_SCREEN_STATE_DRAW_PRIMITIVE_SCREEN_screen2);
            break;
        case HGC_SCREEN_STATE_DRAW_PRIMITIVE_SCREEN_screen2:
            GFX_HGC_DrawScreen_Primitives(screen2);
            GFX_HGC_SetScreenState(HGC_SCREEN_STATE_POST_DRAW_PRIMITIVE_SCREEN_screen2);
            break;
        case HGC_SCREEN_STATE_POST_DRAW_PRIMITIVE_SCREEN_screen2:
            GFX_HGC_SetScreenState(HGC_SCREEN_STATE_DISPLAY_SCREEN_screen2);
            break;
        case HGC_SCREEN_STATE_DISPLAY_SCREEN_screen2:
            break;
        case HGC_SCREEN_STATE_SETUP_SCREEN_screen3:
            GFX_HGC_SetScreenState(HGC_SCREEN_STATE_PRE_DRAW_GOL_SCREEN_screen3);
            break;
        case HGC_SCREEN_STATE_PRE_DRAW_GOL_SCREEN_screen3:
            GFX_HGC_SetScreenState(HGC_SCREEN_STATE_DRAW_GOL_SCREEN_screen3);
            break;
        case HGC_SCREEN_STATE_DRAW_GOL_SCREEN_screen3:
            GFX_HGC_SetupScreen(screen3);
            GFX_HGC_DrawScreen_GOL(screen3);
            GFX_HGC_SetScreenState(HGC_SCREEN_STATE_POST_DRAW_GOL_SCREEN_screen3);
            break;
        case HGC_SCREEN_STATE_POST_DRAW_GOL_SCREEN_screen3:
            GFX_HGC_SetScreenState(HGC_SCREEN_STATE_PRE_DRAW_PRIMITIVE_SCREEN_screen3);
            break;
        case HGC_SCREEN_STATE_PRE_DRAW_PRIMITIVE_SCREEN_screen3:
            GFX_HGC_SetScreenState(HGC_SCREEN_STATE_DRAW_PRIMITIVE_SCREEN_screen3);
            break;
        case HGC_SCREEN_STATE_DRAW_PRIMITIVE_SCREEN_screen3:
            GFX_HGC_DrawScreen_Primitives(screen3);
            GFX_HGC_SetScreenState(HGC_SCREEN_STATE_POST_DRAW_PRIMITIVE_SCREEN_screen3);
            break;
        case HGC_SCREEN_STATE_POST_DRAW_PRIMITIVE_SCREEN_screen3:
            GFX_HGC_SetScreenState(HGC_SCREEN_STATE_DISPLAY_SCREEN_screen3);
            break;
        case HGC_SCREEN_STATE_DISPLAY_SCREEN_screen3:
            break;
        default:
            return true; // release drawing control to GOL by default
    }

    return true; // release drawing control to GOL
}

/******************************************************************************
  Function: 
    void GFX_HGC_SetupScreen( uint8_t  screenId )

  Remarks: 
    Clears current screen and starts a fresh screen with its background color
 */
void GFX_HGC_SetupScreen(uint8_t screenId)
{
    switch (screenId)
    {
        case screen1:
            GFX_ColorSet(GFX_INDEX_0, GFX_RGBConvert(0x00, 0x00, 0x00));
            GFX_ScreenClear(GFX_INDEX_0);

            GFX_GOL_ObjectListFree(GFX_INDEX_0); // free memory for the objects in the previous linked list and start new list
            break;
        case screen2:
            GFX_ColorSet(GFX_INDEX_0, GFX_RGBConvert(0x00, 0x00, 0x00));
            GFX_ScreenClear(GFX_INDEX_0);

            GFX_GOL_ObjectListFree(GFX_INDEX_0); // free memory for the objects in the previous linked list and start new list
            break;
        case screen3:
            GFX_ColorSet(GFX_INDEX_0, GFX_RGBConvert(0x00, 0x00, 0x00));
            GFX_ScreenClear(GFX_INDEX_0);

            GFX_GOL_ObjectListFree(GFX_INDEX_0); // free memory for the objects in the previous linked list and start new list
            break;
        default:
            break;
    }
}


/******************************************************************************
  Function: 
    bool GFX_HGC_ChangeScreen( uint8_t  screenId )

  Output: 
    Returns true if a screenId matches an existing screen identifier

  Remarks: 
    Can be called to initiate GFX Library to draw a new screen
 */
bool GFX_HGC_ChangeScreen(uint8_t screenId)
{
    switch (screenId)
    {
        case screen1:
            GFX_HGC_SetScreenState(HGC_SCREEN_STATE_SETUP_SCREEN_screen1);
            break;
        case screen2:
            GFX_HGC_SetScreenState(HGC_SCREEN_STATE_SETUP_SCREEN_screen2);
            break;
        case screen3:
            GFX_HGC_SetScreenState(HGC_SCREEN_STATE_SETUP_SCREEN_screen3);
            break;
        default:
            return false;
    }

    return true; // release drawing control to GOL
}

/******************************************************************************
  Function: 
    bool GFX_HGC_DrawScreen_GOL( uint8_t  screenId )

  Output: 
    Returns true if a screenId matches an existing screen identifier

  Remarks: 
    HGC-specified GFX GOL objects are drawn here, grouped by screen.
    The draw order is reverse Z-ordered.
 */
bool GFX_HGC_DrawScreen_GOL(uint8_t screenId)
{
    switch (screenId)
    {
        case screen1:
            break;
        case screen2:
            GFX_HGC_DrawItem(Picture1);
            GFX_HGC_DrawItem(StaticText1);
            break;
        case screen3:
            break;
        default:
            return false;
    }

    return true; // release drawing control to GOL
}


/******************************************************************************
  Function: 
    bool GFX_HGC_DrawScreen_Primitives( uint8_t  screenId )

  Output:
    Returns true if a screenId matches an existing screen identifier

  Remarks: 
    HGC-specified GFX Primitives are drawn here, grouped by screen.
    GFX Primitives are drawn after GFX GOL Objects to make sure GFX GOL Objects
    do not cover GFX Primitives
 */
bool GFX_HGC_DrawScreen_Primitives(uint8_t screenId)
{
    switch (screenId)
    {
        case screen1:
            GFX_HGC_DrawItem(Circle1);
            GFX_HGC_DrawItem(Circle2);
            GFX_HGC_DrawItem(Circle3);
            GFX_HGC_DrawItem(Circle4);
            GFX_HGC_DrawItem(Circle5);
            GFX_HGC_DrawItem(Circle6);
            GFX_HGC_DrawItem(Circle7);
            GFX_HGC_DrawItem(Circle8);
            GFX_HGC_DrawItem(Circle9);
            GFX_HGC_DrawItem(Circle10);
            GFX_HGC_DrawItem(Line1);
            GFX_HGC_DrawItem(Line2);
            GFX_HGC_DrawItem(Line3);
            GFX_HGC_DrawItem(Line4);
            GFX_HGC_DrawItem(Line5);
            GFX_HGC_DrawItem(Line6);
            GFX_HGC_DrawItem(Line7);
            GFX_HGC_DrawItem(Line8);
            GFX_HGC_DrawItem(Line9);
            GFX_HGC_DrawItem(Line10);
            GFX_HGC_DrawItem(Line11);
            break;
        case screen2:
            break;
        case screen3:
            GFX_HGC_DrawItem(Rectangle2);
            GFX_HGC_DrawItem(Rectangle3);
            GFX_HGC_DrawItem(Rectangle1);
            GFX_HGC_DrawItem(Rectangle4);
            GFX_HGC_DrawItem(Rectangle5);
            break;
        default:
            return true;
    }

    return true; // release drawing control to GOL
}


/******************************************************************************
  Function: 
    bool GFX_HGC_DrawItem(int itemId)

  Output:
    Returns true if a itemId matches an existing item identifier

  Remarks: 
    Every item specified in every screen in HGC is listed in this function
 */
bool GFX_HGC_DrawItem(int itemId)
{
    switch(itemId)
    {
    case StaticText1:
        hgcObj.pStaticText1Obj = GFX_GOL_StaticTextCreate
                (
                 GFX_INDEX_0,
                 StaticText1,      // button ID
                 GFX_STATICTEXT_LEFT_0,    // left
                 GFX_STATICTEXT_TOP_0,     // top
                 GFX_STATICTEXT_RIGHT_0,   // right
                 GFX_STATICTEXT_BOTTOM_0,  // bottom
                 GFX_STATICTEXT_STATE_0,   // state
                 (GFX_XCHAR*)staticTextStr_0,    // text
                 GFX_STATICTEXT_ALIGNMENT_0,       //alignment
                 GFX_STATICTEXT_SCHEME_0
                 ); // use alternate scheme
        break;
    case Picture1:
        hgcObj.pPicture1Obj = GFX_GOL_PictureControlCreate
                (
                 GFX_INDEX_0,
                 Picture1,      // picture ID
                 GFX_PICTURE_LEFT_0,    // left
                 GFX_PICTURE_TOP_0,     // top
                 GFX_PICTURE_RIGHT_0,   // right                                 
                 GFX_PICTURE_BOTTOM_0,  // bottom
                                 GFX_PICTURE_STATE_0,   // state                 
                 GFX_PICTURE_SCALE_0,     // scale
                 (GFX_RESOURCE_HDR*)&flower16bit,    // bitmap
                 GFX_PICTURE_SCHEME_0
                 );
        break;
                case Line11:
                {
                        GFX_ColorSet(GFX_INDEX_0, GFX_RGBConvert(0xF8, 0xFC, 0xF8));
                        GFX_LineStyleSet(GFX_INDEX_0, GFX_LINE_STYLE_THIN_SOLID);
                        GFX_LineDraw(GFX_INDEX_0,
                                                 240/6*5,   //267,  // p1x
                                                 0,  // p1y
                                                 240/6, //53,  // p2x
                                                 319);  //239); // p2y
                        break;
                }               
                case Line10:
                {
                        GFX_ColorSet(GFX_INDEX_0, GFX_RGBConvert(0xF8, 0xFC, 0xF8));
                        GFX_LineStyleSet(GFX_INDEX_0, GFX_LINE_STYLE_THIN_SOLID);
                        GFX_LineDraw(GFX_INDEX_0,
                                                 240/6*4,   //214,  // p1x
                                                 0,  // p1y
                                                 240/6*2,   //106,  // p2x
                                                 319);  //239); // p2y
                        break;
                }               
                case Line9:
                {
                        GFX_ColorSet(GFX_INDEX_0, GFX_RGBConvert(0xF8, 0xFC, 0xF8));
                        GFX_LineStyleSet(GFX_INDEX_0, GFX_LINE_STYLE_THIN_SOLID);
                        GFX_LineDraw(GFX_INDEX_0,
                                                 240/6*2,   //106,  // p1x
                                                 0,  // p1y
                                                 240/6*4,   //214,  // p2x
                                                 319);  //239); // p2y
                        break;
                }               
                case Line8:
                {
                        GFX_ColorSet(GFX_INDEX_0, GFX_RGBConvert(0xF8, 0xFC, 0xF8));
                        GFX_LineStyleSet(GFX_INDEX_0, GFX_LINE_STYLE_THIN_SOLID);
                        GFX_LineDraw(GFX_INDEX_0,
                                                 240/6, //53,  // p1x
                                                 0,  // p1y
                                                 240/6*5,   //267,  // p2x
                                                 319);  //239); // p2y
                        break;
                }               
                case Line7:
                {
                        GFX_ColorSet(GFX_INDEX_0, GFX_RGBConvert(0xF8, 0xFC, 0xF8));
                        GFX_LineStyleSet(GFX_INDEX_0, GFX_LINE_STYLE_THIN_SOLID);
                        GFX_LineDraw(GFX_INDEX_0,
                                                120,    // 160,  // p1x
                                                 0,  // p1y
                                                120,    // 160,  // p2x
                                                319);    // 239); // p2y
                        break;
                }               
                case Line6:
                {
                        GFX_ColorSet(GFX_INDEX_0, GFX_RGBConvert(0xF8, 0xFC, 0xF8));
                        GFX_LineStyleSet(GFX_INDEX_0, GFX_LINE_STYLE_THIN_SOLID);
                        GFX_LineDraw(GFX_INDEX_0,
                                                 0,  // p1x
                                                 319,   //239,  // p1y
                                                 239,   //319,  // p2x
                                                 0); // p2y
                        break;
                }               
                case Line5:
                {
                        GFX_ColorSet(GFX_INDEX_0, GFX_RGBConvert(0xF8, 0xFC, 0xF8));
                        GFX_LineStyleSet(GFX_INDEX_0, GFX_LINE_STYLE_THIN_SOLID);
                        GFX_LineDraw(GFX_INDEX_0,
                                                 0,  // p1x
                                                 0,  // p1y
                                                 239,   //319,  // p2x
                                                 319);   //239); // p2y
                        break;
                }               
                case Line4: //LIGHT GREEN
                {
                        GFX_ColorSet(GFX_INDEX_0, GFX_RGBConvert(0x00, 0xFC, 0x00));
                        GFX_LineStyleSet(GFX_INDEX_0, GFX_LINE_STYLE_THIN_SOLID);
                        GFX_LineDraw(GFX_INDEX_0,
                                                 239,   //319,  // p1x
                                                 0,  // p1y
                                                 239,   //319,  // p2x
                                                 319);  //239); // p2y
                        break;
                }               
                case Line3: //YELLOW
                {
                        GFX_ColorSet(GFX_INDEX_0, GFX_RGBConvert(0xF8, 0xFC, 0x00));
                        GFX_LineStyleSet(GFX_INDEX_0, GFX_LINE_STYLE_THIN_SOLID);
                        GFX_LineDraw(GFX_INDEX_0,
                                                 0,  // p1x
                                                 0,  // p1y
                                                 0,  // p2x
                                                 319);  //239); // p2y
                        break;
                }               
                case Line2: //BLUE
                {
                        GFX_ColorSet(GFX_INDEX_0, GFX_RGBConvert(0x00, 0x00, 0xF8));
                        GFX_LineStyleSet(GFX_INDEX_0, GFX_LINE_STYLE_THIN_SOLID);
                        GFX_LineDraw(GFX_INDEX_0,
                                                 0,  // p1x
                                                 319,   //239,  // p1y
                                                 239,   //319,  // p2x
                                                 319);  //239); // p2y
                        break;
                }               
                case Line1: //RED
                {
                        GFX_ColorSet(GFX_INDEX_0, GFX_RGBConvert(0xF8, 0x00, 0x00));
                        GFX_LineStyleSet(GFX_INDEX_0, GFX_LINE_STYLE_THIN_SOLID);
                        GFX_LineDraw(GFX_INDEX_0,
                                                 0,  // p1x
                                                 0,  // p1y
                                                 239,   //319,  // p2x
                                                 0); // p2y
                        break;
                }               
                case Rectangle5:
                {
                        GFX_ColorSet(GFX_INDEX_0, GFX_RGBConvert(0x00, 0x00, 0xF8));
                        GFX_LineStyleSet(GFX_INDEX_0, GFX_LINE_STYLE_THIN_SOLID);
                        GFX_RectangleDraw(GFX_INDEX_0,
                                                          65-40,  // p1x
                                                          30+40,  // p1y
                                                          255-40,  // p2x
                                                          210+40); // p2y
                        
                        break;
                }       
                case Rectangle4:
                {
                        GFX_ColorSet(GFX_INDEX_0, GFX_RGBConvert(0x00, 0x00, 0xF8));
                        GFX_LineStyleSet(GFX_INDEX_0, GFX_LINE_STYLE_THIN_SOLID);
                        GFX_RectangleDraw(GFX_INDEX_0,
                                                          80-40,  // p1x
                                                          45+40,  // p1y
                                                          240-40,  // p2x
                                                          195+40); // p2y
                        
                        break;
                }       
                case Rectangle1:
                {
                        GFX_FillStyleSet(GFX_INDEX_0, GFX_FILL_STYLE_ALPHA_COLOR);
                        GFX_ColorSet(GFX_INDEX_0, GFX_RGBConvert(0xF8, 0x00, 0x00));
                        GFX_AlphaBlendingValueSet(GFX_INDEX_0, 100);
                        GFX_RectangleFillDraw(GFX_INDEX_0,
                                                                  125-40,  // p1x
                                                                  90+40,  // p1y
                                                                  195-40,  // p2x
                                                                  150+40); // p2y
                        
                        GFX_ColorSet(GFX_INDEX_0, GFX_RGBConvert(0xF8, 0x00, 0x00));
                        GFX_LineStyleSet(GFX_INDEX_0, GFX_LINE_STYLE_THIN_SOLID);
                        GFX_RectangleDraw(GFX_INDEX_0,
                                                          125-40,  // p1x
                                                          90+40,  // p1y
                                                          195-40,  // p2x
                                                          150+40); // p2y
                        
                        break;
                }       
                case Rectangle3:
                {
                        GFX_FillStyleSet(GFX_INDEX_0, GFX_FILL_STYLE_COLOR);
                        GFX_ColorSet(GFX_INDEX_0, GFX_RGBConvert(0x00, 0xFC, 0x00));
                        GFX_RectangleFillDraw(GFX_INDEX_0,
                                                                  110-40,  // p1x
                                                                  75+40,  // p1y
                                                                  210-40,  // p2x
                                                                  165+40); // p2y
                        
                        GFX_ColorSet(GFX_INDEX_0, GFX_RGBConvert(0x00, 0xFC, 0x00));
                        GFX_LineStyleSet(GFX_INDEX_0, GFX_LINE_STYLE_THIN_SOLID);
                        GFX_RectangleDraw(GFX_INDEX_0,
                                                          110-40,  // p1x
                                                          75+40,  // p1y
                                                          210-40,  // p2x
                                                          165+40); // p2y
                        
                        break;
                }       
                case Rectangle2:
                {
                        GFX_FillStyleSet(GFX_INDEX_0, GFX_FILL_STYLE_COLOR);
                        GFX_ColorSet(GFX_INDEX_0, GFX_RGBConvert(0x00, 0x00, 0xF8));
                        GFX_RectangleFillDraw(GFX_INDEX_0,
                                                                  95-40,  // p1x
                                                                  60+40,  // p1y
                                                                  225-40,  // p2x
                                                                  180+40); // p2y
                        
                        GFX_ColorSet(GFX_INDEX_0, GFX_RGBConvert(0x00, 0x00, 0xF8));
                        GFX_LineStyleSet(GFX_INDEX_0, GFX_LINE_STYLE_THIN_SOLID);
                        GFX_RectangleDraw(GFX_INDEX_0,
                                                          95-40,  // p1x
                                                          60+40,  // p1y
                                                          225-40,  // p2x
                                                          180+40); // p2y
                        
                        break;
                }       
                case Circle10:
                {
                        GFX_ColorSet(GFX_INDEX_0,GFX_RGBConvert(0xF8, 0x00, 0x00));
                        GFX_LineStyleSet(GFX_INDEX_0, GFX_LINE_STYLE_THIN_SOLID);
                        GFX_CircleDraw(GFX_INDEX_0,
                                                   120, //160, // p1x
                                                   160, //120, // p1y
                                                   3); // radius
                                                   
                        break;
                }       
                case Circle9:
                {
                        GFX_ColorSet(GFX_INDEX_0,GFX_RGBConvert(0xF8, 0x00, 0x00));
                        GFX_LineStyleSet(GFX_INDEX_0, GFX_LINE_STYLE_THIN_SOLID);
                        GFX_CircleDraw(GFX_INDEX_0,
                                                   120, //160, // p1x
                                                   160, //120, // p1y
                                                   16); // radius
                                                   
                        break;
                }       
                case Circle8:
                {
                        GFX_ColorSet(GFX_INDEX_0,GFX_RGBConvert(0xF8, 0x00, 0x00));
                        GFX_LineStyleSet(GFX_INDEX_0, GFX_LINE_STYLE_THIN_SOLID);
                        GFX_CircleDraw(GFX_INDEX_0,
                                                   120, //160, // p1x
                                                   160, //120, // p1y
                                                   29); // radius
                                                   
                        break;
                }       
                case Circle7:
                {
                        GFX_ColorSet(GFX_INDEX_0,GFX_RGBConvert(0xF8, 0x00, 0x00));
                        GFX_LineStyleSet(GFX_INDEX_0, GFX_LINE_STYLE_THIN_SOLID);
                        GFX_CircleDraw(GFX_INDEX_0,
                                                   120, //160, // p1x
                                                   160, //120, // p1y
                                                   42); // radius
                                                   
                        break;
                }       
                case Circle6:
                {
                        GFX_ColorSet(GFX_INDEX_0,GFX_RGBConvert(0xF8, 0x00, 0x00));
                        GFX_LineStyleSet(GFX_INDEX_0, GFX_LINE_STYLE_THIN_SOLID);
                        GFX_CircleDraw(GFX_INDEX_0,
                                                   120, //160, // p1x
                                                   160, //120, // p1y
                                                   55); // radius
                                                   
                        break;
                }       
                case Circle5:
                {
                        GFX_ColorSet(GFX_INDEX_0,GFX_RGBConvert(0xF8, 0x00, 0x00));
                        GFX_LineStyleSet(GFX_INDEX_0, GFX_LINE_STYLE_THIN_SOLID);
                        GFX_CircleDraw(GFX_INDEX_0,
                                                   120, //160, // p1x
                                                   160, //120, // p1y
                                                   68); // radius
                                                   
                        break;
                }       
                case Circle4:
                {
                        GFX_ColorSet(GFX_INDEX_0,GFX_RGBConvert(0xF8, 0x00, 0x00));
                        GFX_LineStyleSet(GFX_INDEX_0, GFX_LINE_STYLE_THIN_SOLID);
                        GFX_CircleDraw(GFX_INDEX_0,
                                                   120, //160, // p1x
                                                   160, //120, // p1y
                                                   81); // radius
                                                   
                        break;
                }       
                case Circle3:
                {
                        GFX_ColorSet(GFX_INDEX_0,GFX_RGBConvert(0xF8, 0x00, 0x00));
                        GFX_LineStyleSet(GFX_INDEX_0, GFX_LINE_STYLE_THIN_SOLID);
                        GFX_CircleDraw(GFX_INDEX_0,
                                                   120, //160, // p1x
                                                   160, //120, // p1y
                                                   94); // radius
                                                   
                        break;
                }       
                case Circle2:
                {
                        GFX_ColorSet(GFX_INDEX_0,GFX_RGBConvert(0xF8, 0x00, 0x00));
                        GFX_LineStyleSet(GFX_INDEX_0, GFX_LINE_STYLE_THIN_SOLID);
                        GFX_CircleDraw(GFX_INDEX_0,
                                                   120, //160, // p1x
                                                   160, //120, // p1y
                                                   107); // radius
                                                   
                        break;
                }       
                case Circle1:
                {
                        GFX_ColorSet(GFX_INDEX_0,GFX_RGBConvert(0xF8, 0x00, 0x00));
                        GFX_LineStyleSet(GFX_INDEX_0, GFX_LINE_STYLE_THIN_SOLID);
                        GFX_CircleDraw(GFX_INDEX_0,
                                                   120, //160, // p1x
                                                   160, //120, // p1y
                                                   120); // radius
                                                   
                        break;
                }       
        default:
                return false; // process by default
    }

    return true;
}

/******************************************************************************
  Function: 
    bool GFX_HGC_MsgStaticTexts(uint16_t objMsg, GFX_GOL_OBJ_HEADER *pObj)

  Output:
    Returns true if a Object ID matches an existing item identifier

  Remarks: 
    Handles GFX GOL Static Text events
 */
bool GFX_HGC_MsgStaticTexts(uint16_t objMsg, GFX_GOL_OBJ_HEADER *pObj)
{
    switch (GFX_GOL_ObjectIDGet(pObj))
    {
        default:
            return false; // default false as it is not processed
    }    
}

/******************************************************************************
  Function: 
    bool GFX_HGC_MsgPictures(uint16_t objMsg, GFX_GOL_OBJ_HEADER *pObj)

  Output:
    Returns true if a Object ID matches an existing item identifier

  Remarks: 
    Handles GFX GOL Picture Control events
 */
bool GFX_HGC_MsgPictures(uint16_t objMsg, GFX_GOL_OBJ_HEADER *pObj)
{
    switch (GFX_GOL_ObjectIDGet(pObj))
    {
        default:
            return false; // default false as it is not processed
    }    
}


 <動作結果>

1. ピクチャー
  以下、各画面

    液晶各画面
 
 A  
 B  



2.、動画  -----> YouTube